Christopher Tyler

How to List Active Connections on PostgreSQL

From https://stackoverflow.com/questions/27435839/how-to-list-active-connections-on-postgresql

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
SELECT 
    pid
    ,datname
    ,usename
    ,application_name
    ,client_hostname
    ,client_port
    ,backend_start
    ,query_start
    ,query
    ,state
FROM pg_stat_activity
WHERE state = 'active';

If you want to know the idle ones, use idle.

<< Previous Post

|

Next Post >>

#Pg_stat_activity #Postgresql