pg_stat_replication_slots 是一个 统计信息视图,显示有关逻辑复制槽使用情况的统计信息,特别是关于从 ReorderBuffer 溢出到磁盘的事务。
pg_stat_replication_slots 在 PostgreSQL 14 中添加。
重置统计信息
可以通过调用函数 pg_stat_reset_replication_slot(slot_name) 来重置特定逻辑复制槽的统计信息。
可以通过调用 pg_stat_reset_replication_slot(NULL) 来重置所有逻辑复制槽的统计信息。
按 PostgreSQL 版本定义
pg_stat_replication_slots (PostgreSQL 19)
View "pg_catalog.pg_stat_replication_slots"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
slot_name | text | | |
spill_txns | bigint | | |
spill_count | bigint | | |
spill_bytes | bigint | | |
stream_txns | bigint | | |
stream_count | bigint | | |
stream_bytes | bigint | | |
total_txns | bigint | | |
total_bytes | bigint | | |
stats_reset | timestamp with time zone | | |
pg_stat_replication_slots (PostgreSQL 18)
View "pg_catalog.pg_stat_replication_slots"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
slot_name | text | | |
spill_txns | bigint | | |
spill_count | bigint | | |
spill_bytes | bigint | | |
stream_txns | bigint | | |
stream_count | bigint | | |
stream_bytes | bigint | | |
total_txns | bigint | | |
total_bytes | bigint | | |
stats_reset | timestamp with time zone | | |
pg_stat_replication_slots (PostgreSQL 17)
View "pg_catalog.pg_stat_replication_slots"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
slot_name | text | | |
spill_txns | bigint | | |
spill_count | bigint | | |
spill_bytes | bigint | | |
stream_txns | bigint | | |
stream_count | bigint | | |
stream_bytes | bigint | | |
total_txns | bigint | | |
total_bytes | bigint | | |
stats_reset | timestamp with time zone | | |
pg_stat_replication_slots (PostgreSQL 16)
View "pg_catalog.pg_stat_replication_slots"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
slot_name | text | | |
spill_txns | bigint | | |
spill_count | bigint | | |
spill_bytes | bigint | | |
stream_txns | bigint | | |
stream_count | bigint | | |
stream_bytes | bigint | | |
total_txns | bigint | | |
total_bytes | bigint | | |
stats_reset | timestamp with time zone | | |
pg_stat_replication_slots (PostgreSQL 15)
View "pg_catalog.pg_stat_replication_slots"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
slot_name | text | | |
spill_txns | bigint | | |
spill_count | bigint | | |
spill_bytes | bigint | | |
stream_txns | bigint | | |
stream_count | bigint | | |
stream_bytes | bigint | | |
total_txns | bigint | | |
total_bytes | bigint | | |
stats_reset | timestamp with time zone | | |
pg_stat_replication_slots (PostgreSQL 14)
View "pg_catalog.pg_stat_replication_slots"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
slot_name | text | | |
spill_txns | bigint | | |
spill_count | bigint | | |
spill_bytes | bigint | | |
stream_txns | bigint | | |
stream_count | bigint | | |
stream_bytes | bigint | | |
total_txns | bigint | | |
total_bytes | bigint | | |
stats_reset | timestamp with time zone | | |
变更历史
- PostgreSQL 19
- 添加了列
mem_exceeded_count(commit d3b6183d)
- 添加了列
- PostgreSQL 14
- 添加 (初始 commit 98681675)
示例
订阅同步期间 pg_stat_replication_slots 的示例内容
postgres=# SELECT * FROM pg_stat_replication_slots\gx -[ RECORD 1 ]+----------------------------------------- slot_name | test_subscription spill_txns | 0 spill_count | 0 spill_bytes | 0 stream_txns | 0 stream_count | 0 stream_bytes | 0 total_txns | 0 total_bytes | 0 stats_reset | -[ RECORD 2 ]+----------------------------------------- slot_name | pg_131705_sync_16417_7036528642179786015 spill_txns | 0 spill_count | 0 spill_bytes | 0 stream_txns | 0 stream_count | 0 stream_bytes | 0 total_txns | 0 total_bytes | 0 stats_reset |
参考资料
- PostgreSQL 文档: pg_stat_replication_slots
