Skip to content

SQL - PostgreSQL - Get Current DB Sessions

Source: https://www.postgresql.org/docs/current/monitoring-stats.html

-- Ref: https://www.postgresql.org/docs/current/monitoring-stats.html
-- Get current DB Sessions
SELECT count(*) as stat_count, state 
FROM pg_stat_activity 
WHERE "query"::text not ilike '%pg_stat_activity%' 
GROUP BY "state"

Backlinks:

list from [[SQL - PostgreSQL - Get Current DB Sessions]] AND -"Changelog"