Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Last active September 1, 2021 07:44
Show Gist options
  • Save StevenJL/eced77f8510348cff6bc5026babab6f4 to your computer and use it in GitHub Desktop.
Save StevenJL/eced77f8510348cff6bc5026babab6f4 to your computer and use it in GitHub Desktop.
Slowest queries right now
# See the slowest queries right now
SELECT
pid,
age(clock_timestamp(), query_start) as time_running,
substr(query, 0, 75)
FROM pg_stat_activity WHERE state != 'idle'
ORDER BY time_running DESC;
# pid | time_running | query
# 123 | 00:00:29 | SELECT users WHERE email ILIKE '%teemo%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment