Home > Mobile >  How to know which JOIN takes more time in case of multiple Joins?
How to know which JOIN takes more time in case of multiple Joins?

Time:12-24

Consider the following query:

SELECT *  
FROM Table1
INNER JOIN Table2 ON Condition1
INNER JOIN Table3 ON Condition2
INNER JOIN Table4 ON Condition3
INNER JOIN Table5 ON Condition4;

Is there a way to know which join takes more time when executing this query?

CodePudding user response:

You can use EXPLAIN (ANALYZE) /* your query */ to find out such details. Look at the actual time, but consider than the results are cumulative, that is, you have to subtract the time from the lower nodes to get the net time of a node.

You can use https://explain.depesz.com for such an execution plan, that will calculate the net time for each step for you.

  • Related