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,
		datname,
		REGEXP_REPLACE(REGEXP_REPLACE(query, 'SET.*?;', 'SET...;', 'g'), '\s+', ' ', 'g')
	FROM 
		pg_stat_activity

docs

Date: 2018-10-04

Tags:  postgresql

Share: