HOW TO INTERPRET POSTGRESQL EXPLAIN ANALYZE OUTPUT
https://www.cybertec-postgresql.com/en/how-to-interpret-postgresql-explain-analyze-output/
EXPLAIN (ANALYZE, BUFFERS) (with track_io_timing turned on) will show you everything you need to know to diagnose SQL statement performance problems.
What to focus on in EXPLAIN ANALYZE output
-
Find the nodes where most of the execution time was spent.
-
Find the lowest node where the estimated row count is significantly different from the actual row count. Very often, this is the cause of bad performance, and the long execution time somewhere else is only a consequence of a bad plan choice based on a bad estimate. “Significantly different” typically means a factor of 10 or so.
-
Find long running sequential scans with a filter condition that removes many rows. These are g