Guest User

Untitled

a guest
Mar 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. CREATE TABLE monitoring.pg_stat_statements AS SELECT now()::timestamp(0) as time, pg_roles.rolname, query,
  2. round(total_time::numeric, 2) AS total_time,
  3. calls,
  4. round(mean_time::numeric, 2) AS mean,
  5. round((100 * total_time /
  6. sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu
  7. FROM pg_stat_statements
  8. INNER JOIN pg_roles ON pg_stat_statements.userid = pg_roles.oid
  9. ORDER BY total_time DESC
  10. LIMIT 20;
  11.  
  12.  
  13. insert into monitoring.pg_stat_statements SELECT now()::timestamp(0) as time, pg_roles.rolname, query,
  14. round(total_time::numeric, 2) AS total_time,
  15. calls,
  16. round(mean_time::numeric, 2) AS mean,
  17. round((100 * total_time /
  18. sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu
  19. FROM pg_stat_statements
  20. INNER JOIN pg_roles ON pg_stat_statements.userid = pg_roles.oid
  21. ORDER BY total_time DESC
  22. LIMIT 20;
Add Comment
Please, Sign In to add comment