Hi Team, This is regarding query latency , sharin...
# troubleshooting
a
Hi Team, This is regarding query latency , sharing the query template below. master_listing_table: - table type: Realtime table - row count: 10mil master_listing_table_minor: - table type: Realtime table - row count: 700k fact_table : - table type: Offline table - row count: 65mil - Subquery Row Count: 100k-500k
Copy code
SELECT ...
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?
g
Two tools are very useful to optimize a query: 1. Explain plan 2. stage stats Try to use them to compare the two queries and feel free to share the results here
a
Hey @Gonzalo Ortiz, i checked the stage stats for query with Order by, 11 stages are present for query without Order by only 1. Stage1, Stage2 and Stage11. With Order By
Copy code
"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
Copy code
"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"
      ]
    }
  }
b
Hi. It'd be better to share actual query, table config, execution plan (with explainAskingServer option) and stats. That's because when it comes to query performance, the devil is in the details.
g
Also… these stage stats look like the older stage stats. Would it be possible to upgrade to Pinot 1.2.0?
a
Hey @Gonzalo Ortiz , We are working on the upgrade. Will inform asap