Skip to content

Instantly share code, notes, and snippets.

@valterlobo
Last active April 20, 2021 16:33
Show Gist options
  • Save valterlobo/859b55b551c05b2114370af19f4b4df2 to your computer and use it in GitHub Desktop.
Save valterlobo/859b55b551c05b2114370af19f4b4df2 to your computer and use it in GitHub Desktop.
PostgreSQL active connection

select pid as process_id, usename as username, datname as database_name, client_addr as client_address, application_name, backend_start, state, state_change from pg_stat_activity;

-- process_id - process ID of this backend

-- username - name of the user logged into this backend

-- database_name - name of the database this backend is connected to

-- client_address - IP address of the client connected to this backend

-- application_name - name of the application that is connected to this backend

-- backend_start - time when this process was started. For client backends, this is the time the client connected to the server.

-- state - current overall state of this backend. Possible values are: active idle idle in transaction idle in transaction (aborted) fastpath function call disabled

-- state_change - time when the state was last changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment