Last active
October 18, 2020 04:34
-
-
Save jwhitehorn/16f193cc5e2aec755e828fc21e108b02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with running_queries as ( | |
select | |
pid, | |
datname as database_name, | |
(case when state='active' then now() else state_change end) - query_start as run_time, | |
backend_start, | |
xact_start, | |
query_start, | |
state_change, | |
wait_event_type, | |
wait_event, | |
state, | |
query | |
from pg_stat_activity | |
where query not like '%pg_stat_activity%' | |
) | |
select * | |
from running_queries | |
order by run_time desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment