pg_wait_events 是一个 系统目录 视图,它提供了等待事件的描述。
pg_wait_events 在 PostgreSQL 17 中被添加。
变更历史
- PostgreSQL 17
- 添加 (commit 1e68e43d)
示例
pg_wait_events 的示例内容
postgres=# SELECT * FROM pg_wait_events LIMIT 3; 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 (3 rows)
pg_wait_events 可以与 pg_stat_activity 连接。
postgres=# SELECT psa.pid, psa.application_name, psa.wait_event,
we.description
FROM pg_stat_activity psa
JOIN pg_wait_events we
ON (psa.wait_event_type = we.type AND
psa.wait_event = we.name);
pid | application_name | wait_event | description
-------+------------------+---------------------+--------------------------------------------------------------
16252 | | AutoVacuumMain | Waiting in main loop of autovacuum launcher process
16249 | | BgWriterMain | Waiting in main loop of background writer process
16248 | | CheckpointerMain | Waiting in main loop of checkpointer process
16253 | | LogicalLauncherMain | Waiting in main loop of logical replication launcher process
16251 | | WalWriterMain | Waiting in main loop of WAL writer process
(5 rows)
参考资料
- PostgreSQL 文档: pg_wait_events
