postgres show activity code example
Example 1: check connections to database postgres
SELECT * FROM pg_stat_activity WHERE datname='db_name';
Example 2: see active transactions postgres
SELECT
pid
,datname
,usename
,application_name
,client_hostname
,client_port
,backend_start
,query_start
,query
FROM pg_stat_activity
WHERE state <> 'idle'
AND pid<>pg_backend_pid();