The Statement Statistics Extension: Find Which Query Shape Costs the Most Total Time
pg_stat_statements is a PostgreSQL extension that records every query shape the server has run, with call count, total and mean execution time, and rows returned. It is how you answer 'which query should I fix first?' on a real server, and the answer is often not the slowest query but a fast one called two hundred thousand times. Sorting by total time rather than mean time is the trick, because total time is where the server's day actually went. Recent versions also report percentile-friendly statistics and planning time separately from execution time.
Questions this Concept answers
Why is sorting `pg_stat_statements` by total time usually more useful than sorting by mean time?
J
jeremy
Video
Finding Slow PostgreSQL Queries with pg_stat_statements
This concept covers finding slow PostgreSQL queries with the `pg_stat_statements` extension, a built-in module that records cumulative execution statistics for every SQL statement the database runs. …