The pg_stat_activity view will have one row per server process, showing information related to the current activity of that process.
\d pg_stat_activity;
View "pg_catalog.pg_stat_activity"
Column | Type | Modifiers
------------------+--------------------------+-----------
datid | oid |
datname | name |
pid | bigint |
sessionid | bigint |
usesysid | oid |
usename | name |
application_name | text |
client_addr | inet |
client_hostname | text |
client_port | integer |
backend_start | timestamp with time zone |
xact_start | timestamp with time zone |
query_start | timestamp with time zone |
state_change | timestamp with time zone |
waiting | boolean |
enqueue | text |
state | text |
resource_pool | name |
query_id | bigint |
query | text |
connection_info | text |
unique_sql_id | bigint |
trace_id | text |
select * from pg_stat_activity;
select datname, backend_start, connection_info from pg_stat_activity;