Anish Nair
01/16/2025, 2:08 PMSELECT ...
FROM master_listing_table a
FULL JOIN
(
SELECT dim1,dim2.. from fact_table
WHERE ...
group by ...
) factTbl
ON ...
LEFT JOIN master_listing_table_minor
ON ...
WHERE...
ORDER BY factColumn
LIMIT 25
Query Time: 10-30 seconds avg
Same query without ORDER BY, 2-3 seconds avg
Can someone help with optimizing query for this case?Gonzalo Ortiz
01/17/2025, 2:01 AMAnish Nair
01/17/2025, 7:13 AM"stageStats": {
"1": {
"numBlocks": 1,
"numRows": 25,
"stageExecutionTimeMs": 9036,
"stageExecutionUnit": 1,
"stageExecWallTimeMs": 9036
},
"2": {
"numBlocks": 4,
"numRows": 100,
"stageExecutionTimeMs": 31732,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 9032
},
"3": {
"numBlocks": 4064,
"numRows": 10461988,
"stageExecutionTimeMs": 28986,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 7547
},
"4": {
"numBlocks": 2032,
"numRows": 20260538,
"stageExecutionTimeMs": 13225,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 7003,
"tableNames": [
"master_listing_table_minor"
]
},
"5": {
"numBlocks": 4,
"numRows": 336081,
"stageExecutionTimeMs": 7685,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 1947
},
"6": {
"numBlocks": 4,
"numRows": 336081,
"stageExecutionTimeMs": 6064,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 1558
},
"7": {
"numBlocks": 829,
"numRows": 2085545,
"stageExecutionTimeMs": 5320,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 1389
},
"8": {
"numBlocks": 434,
"numRows": 4191620,
"stageExecutionTimeMs": 2386,
"stageExecutionUnit": 8,
"stageExecWallTimeMs": 1313,
"tableNames": [
"fact_table"
]
},
"9": {
"numBlocks": 7,
"numRows": 43078,
"stageExecutionTimeMs": 23,
"stageExecutionUnit": 2,
"stageExecWallTimeMs": 16,
"tableNames": [
"dim_table2"
]
},
"10": {
"numBlocks": 3,
"numRows": 5608,
"stageExecutionTimeMs": 7,
"stageExecutionUnit": 2,
"stageExecWallTimeMs": 4,
"tableNames": [
"dim_table1"
]
},
"11": {
"numBlocks": 138,
"numRows": 1328354,
"stageExecutionTimeMs": 468,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 230,
"tableNames": [
"master_listing_table_minor"
]
}
}
Without Order BY
"stageStats": {
"1": {
"numBlocks": 1,
"numRows": 25,
"stageExecutionTimeMs": 7723,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 1939
},
"2": {
"numBlocks": 4,
"numRows": 100,
"stageExecutionTimeMs": 7712,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 1937
},
"11": {
"numBlocks": 138,
"numRows": 1328358,
"stageExecutionTimeMs": 454,
"stageExecutionUnit": 4,
"stageExecWallTimeMs": 278,
"tableNames": [
"master_listing_table_minor"
]
}
}Bolek Ziobrowski
01/17/2025, 3:27 PMGonzalo Ortiz
01/17/2025, 8:55 PMAnish Nair
01/20/2025, 6:22 AM