Current connections/activity in PostgreSQL


Activity is stored in the pg_stat_activity table:

SELECT * FROM pg_stat_activity

A more useful query:

SELECT
		usename,
		application_name, 
		client_addr,
		state,
		REGEXP_REPLACE(REGEXP_REPLACE(query, 'SET.*?;', 'SET...;', 'g'), '\s+', ' ', 'g')
	FROM 
		pg_stat_activity

docs

Tags:  postgresql

Share: