Checking live traffic

Whenever I inspect a system, there is a system view I prefer to inspect first before digging deeper. I am, of course, talking about pg_stat_activity. The idea behind this view is to give you a chance to figure out what is going on right now.

Here's how it works:

test=# \d pg_stat_activity  View "pg_catalog.pg_stat_activity" Column           |           Type           | Collation | Nullable | Default ------------------+--------------------------+-----------+----------+--------- datid            | oid                      |           |          |  datname          | name                     |           |          |  pid              | integer                  |           |          |  usesysid         | oid                      |           |          |  usename          | name                     |           |          |  application_name | text                     |           |          |  client_addr      | inet                     |           |          |  client_hostname  | text                     |           |          |  client_port      | integer                  |           |          |  backend_start    | timestamp with time zone |           |          |  xact_start ...

Get Mastering PostgreSQL 12 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.