Skip to content

Instantly share code, notes, and snippets.

@GeorgiyDemo
Created July 13, 2022 21:09
Show Gist options
  • Select an option

  • Save GeorgiyDemo/eda1151e057f27139b565d47fd8df0ad to your computer and use it in GitHub Desktop.

Select an option

Save GeorgiyDemo/eda1151e057f27139b565d47fd8df0ad to your computer and use it in GitHub Desktop.
Check performance of Postgres DB via pg_stat_statements lib
SELECT
substring(query, 1, 50) AS short_query,
round(total_exec_time::numeric, 2) AS total_exec_time,
calls, round(mean_exec_time::numeric, 2) AS mean,
round ((100 * total_exec_time / sum(total_exec_time::numeric) OVER ())::numeric, 2) AS percentage_overall
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 35;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment