How to view long-running and active queries in postgresql? DBA scripts to view long-running and active queries in postgresql?
Ezana Answered question 17/04/2023
To view long-running queries:
select current_timestamp - query_start as runtime, datname, usename, query from pg_stat_activity where state != 'idle' order by 1 desc;
To view active queries:
SELECT datname,usename,query FROM pg_stat_activity WHERE state != 'idle' ;
Ezana Answered question 17/04/2023