CertGrid CertGrid
Hands-on Lab·PostgreSQL

PostgreSQL pg_stat_activity and Session Control

The first view anyone opens on a busy server - and the one that quietly lies to you. As a non-superuser it showed ten of eleven sessions as nothing but a pid.

Monitoring and Operations Guide 38 of 47 Intermediate

Written against the versions above. `io worker` appears in `backend_type` from PostgreSQL 18, which introduced asynchronous I/O. On 17 and earlier you will see three fewer background processes here.

Every command on this page ran on db-a01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB

Before you start

  1. Look at every session on the server

  2. Find out why most of it was blank

  3. Watch a query while it runs

  4. Cancel it

  5. Spot a transaction holding on

  6. Terminate it, and see the difference

Official sources