May 2018
Intermediate to advanced
576 pages
30h 25m
English
Run this query to look at the top 10 highest workloads on your server side:
postgres=# SELECT calls, total_time, query FROM pg_stat_statements ORDER BY total_time DESC LIMIT 10;
The output is ordered by total_time, so it doesn't matter whether it was a single query or thousands of smaller queries.
There are many additional columns useful in tracking down further information about particular entries:
postgres=# \d pg_stat_statements View "public.pg_stat_statements" Column | Type | Modifiers ---------------------+------------------+----------- userid | oid | dbid | oid | queryid | bigint | query | text | calls | bigint | total_time | double precision | min_time | double precision | max_time | double precision | mean_time ...