pg_stat_archiver 是一个 统计视图,显示通过 archive_command 参数归档的 WAL 文件的状态信息,包括上次成功和失败的归档尝试时间。
pg_stat_archiver 在 PostgreSQL 9.4 中被添加。
用法
pg_stat_archiver 汇总了成功归档的 WAL 文件和归档失败的 WAL 文件的累计总数,并记录每次成功/失败的文件名和最后时间。
可以通过执行 pg_stat_reset_shared('archiver') 来重置统计信息。
按 PostgreSQL 版本定义
pg_stat_archiver (PostgreSQL 19)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 18)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 17)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 16)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 15)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 14)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 13)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 12)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 11)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 10)
View "pg_catalog.pg_stat_archiver"
Column | Type | Collation | Nullable | Default
--------------------+--------------------------+-----------+----------+---------
archived_count | bigint | | |
last_archived_wal | text | | |
last_archived_time | timestamp with time zone | | |
failed_count | bigint | | |
last_failed_wal | text | | |
last_failed_time | timestamp with time zone | | |
stats_reset | timestamp with time zone | | |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 9.6)
View "pg_catalog.pg_stat_archiver"
Column | Type | Modifiers
--------------------+--------------------------+-----------
archived_count | bigint |
last_archived_wal | text |
last_archived_time | timestamp with time zone |
failed_count | bigint |
last_failed_wal | text |
last_failed_time | timestamp with time zone |
stats_reset | timestamp with time zone |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 9.5)
View "pg_catalog.pg_stat_archiver"
Column | Type | Modifiers
--------------------+--------------------------+-----------
archived_count | bigint |
last_archived_wal | text |
last_archived_time | timestamp with time zone |
failed_count | bigint |
last_failed_wal | text |
last_failed_time | timestamp with time zone |
stats_reset | timestamp with time zone |
文档: pg_stat_archiver
pg_stat_archiver (PostgreSQL 9.4)
View "pg_catalog.pg_stat_archiver"
Column | Type | Modifiers
--------------------+--------------------------+-----------
archived_count | bigint |
last_archived_wal | text |
last_archived_time | timestamp with time zone |
failed_count | bigint |
last_failed_wal | text |
last_failed_time | timestamp with time zone |
stats_reset | timestamp with time zone |
文档: pg_stat_archiver
变更历史
此视图自引入以来(在 PostgreSQL 9.4 中)未被修改。
- PostgreSQL 9.4
- 已添加(提交 9132b189)
示例
postgres=# SELECT * FROM pg_stat_archiver\gx Expanded display is on. -[ RECORD 1 ]------+------------------------------ archived_count | 0 last_archived_wal | last_archived_time | failed_count | 135 last_failed_wal | 000000010000000000000001 last_failed_time | 2019-06-10 22:34:09.730097+02 stats_reset | 2019-06-10 21:50:35.053854+02
参考资料
- PostgreSQL文档: pg_stat_archiver 视图
有用链接
- PostgreSQL 9.4 和 pg_stat_archiver 如何改进 WAL 归档监控 - 2015 年 1 月 2ndQuadrant 博客文章
- 期待 9.4 - 添加 pg_stat_archiver 统计视图。 - 2014 年 1 月“select * from depesz;”博客文章
