As development of PostgreSQL 17 already started there are already some commits which bring in new functionality. One of them introduces a new catalog view called “pg_wait_events”. As the same implies, this view lists the known wait events for PostgreSQL. Many of those wait events came in over time since the “wait_event_type” and “wait_event” columns have been to PostgreSQL 9.6.

Up to now you either have to go to the documentation to get the full list of wait events, or you can have a look at wait_event_names.txt in the source code:

postgres@debian12-pg:/home/postgres/postgresql/ [pgdev] find . -name wait_event_names.txt
./src/backend/utils/activity/wait_event_names.txt
postgres@debian12-pg:/home/postgres/postgresql/ [pgdev] head -10 ./src/backend/utils/activity/wait_event_names.txt
#
# wait_event_names.txt
#      PostgreSQL wait events
#
# Copyright (c) 2023, PostgreSQL Global Development Group
#
# This list serves as the basis for generating source and documentation files
# related to wait events.
#
# The files generated from this one are:

In fact, pg_wait_events gets its content from this text file, so this is the source of truth. Looking at the view itself, it is very simple:

postgres=# \d pg_wait_events 
          View "pg_catalog.pg_wait_events"
   Column    | Type | Collation | Nullable | Default 
-------------+------+-----------+----------+---------
 type        | text |           |          | 
 name        | text |           |          | 
 description | text |           |          | 

There is a type, a name and the description of the wait event:

postgres=# select * from pg_wait_events limit 5;
   type   |       name        |                     description                     
----------+-------------------+-----------------------------------------------------
 Activity | ArchiverMain      | Waiting in main loop of archiver process
 Activity | AutoVacuumMain    | Waiting in main loop of autovacuum launcher process
 Activity | BgWriterHibernate | Waiting in background writer process, hibernating
 Activity | BgWriterMain      | Waiting in main loop of background writer process
 Activity | CheckpointerMain  | Waiting in main loop of checkpointer process
(5 rows)

The view for its own might not be very useful except for having access to the description of the wait events directly inside PostgreSQL. It gets more useful if you join the view to pg_stat_activity. For getting an idea how that looks like lets generate a wait in a first session:

postgres=# begin;
BEGIN
postgres=*# select * from t;
--
(0 rows)

In a second session join pg_stat_activity with pg_wait_events and you’ll see the whole description of the wait event beside the wait, which is very handy as it gives you more information about the wait event:

postgres=# select a.datname, a.usename, a.state, a.wait_event_type, a.wait_event, b.description 
             from pg_stat_activity a 
             join pg_wait_events b 
               on a.wait_event_type = b.type 
              and a.wait_event = b.name;
 datname  | usename  |        state        | wait_event_type |     wait_event      |                         description                          
----------+----------+---------------------+-----------------+---------------------+--------------------------------------------------------------
          |          |                     | Activity        | ArchiverMain        | Waiting in main loop of archiver process
          |          |                     | Activity        | AutoVacuumMain      | Waiting in main loop of autovacuum launcher process
          |          |                     | Activity        | BgWriterHibernate   | Waiting in background writer process, hibernating
          |          |                     | Activity        | CheckpointerMain    | Waiting in main loop of checkpointer process
          | postgres |                     | Activity        | LogicalLauncherMain | Waiting in main loop of logical replication launcher process
          |          |                     | Activity        | WalWriterMain       | Waiting in main loop of WAL writer process
 postgres | postgres | idle in transaction | Client          | ClientRead          | Waiting to read data from the client
(7 rows)

Nice, thanks to all involved.