Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE monitoring.pg_stat_statements AS SELECT now()::timestamp(0) as time, pg_roles.rolname, query,
- round(total_time::numeric, 2) AS total_time,
- calls,
- round(mean_time::numeric, 2) AS mean,
- round((100 * total_time /
- sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu
- FROM pg_stat_statements
- INNER JOIN pg_roles ON pg_stat_statements.userid = pg_roles.oid
- ORDER BY total_time DESC
- LIMIT 20;
- insert into monitoring.pg_stat_statements SELECT now()::timestamp(0) as time, pg_roles.rolname, query,
- round(total_time::numeric, 2) AS total_time,
- calls,
- round(mean_time::numeric, 2) AS mean,
- round((100 * total_time /
- sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu
- FROM pg_stat_statements
- INNER JOIN pg_roles ON pg_stat_statements.userid = pg_roles.oid
- ORDER BY total_time DESC
- LIMIT 20;
Add Comment
Please, Sign In to add comment