Skip to content

Instantly share code, notes, and snippets.

@smith3v
Created August 29, 2019 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smith3v/2467a02e0d03e3b91a4e11ed7969e315 to your computer and use it in GitHub Desktop.
Save smith3v/2467a02e0d03e3b91a4e11ed7969e315 to your computer and use it in GitHub Desktop.
Query to look the current activity in PG cluster
select (now() - query_start), datname, pid, usename, client_addr, client_port, state, CASE WHEN char_length(query) > 244 THEN substring(query, 1, 200) || ' .. ' || substring(query FROM '.{200}$') ELSE query END AS short_query from pg_stat_activity;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment