Here is a script that checks current active sessions in PostgreSQL
SELECT datname, usename, application_name, now() - backend_start AS "Session duration", pid, query FROM pg_stat_activity WHERE state = 'active' ORDER BY "Session duration" DESC;
Cheers!
Leave a Reply