pg_stat_archiver

一个显示WAL归档状态信息的统计视图

pg_stat_archiver 是一个 统计视图,显示通过 archive_command 参数归档的 WAL 文件的状态信息,包括上次成功和失败的归档尝试时间。

pg_stat_archiverPostgreSQL 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 中)未被修改。

示例

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

分类

备份, 复制, 统计/监控视图, WAL

另请参阅

pg_stat_replication, archive_mode, archive_command, pg_ls_archive_statusdir(), pg_stat_reset_shared()

反馈

就“pg_stat_archiver”提交任何评论、建议或更正,请在此处 提交