myorama
8/27/2019 - 11:54 AM

slow queries with pg_stat_statements

SELECT queryid, calls,
  trunc(total_time::numeric, 2) as total_time,
  trunc(mean_time::numeric, 2) as mean_time,
  rows
FROM pg_stat_statements
ORDER BY total_time DESC
LIMIT 10;
select queryid, calls, total_time, min_time, max_time, mean_time, rows/calls as rows, 
    	pg_size_pretty(shared_blks_hit*1024*8) as shared_blks_hit_size, 
    	pg_size_pretty(shared_blks_hit*1024*8/calls) as mean_shared_bkls_hit_size 
 from pg_stat_statements order by total_time desc limit 10;