pg_stat_slru
是一个 统计视图,显示有关缓存页面访问的信息。具体来说,它提供了一种监控各种使用 SLRU(简单最近最少使用)算法进行缓存驱逐的较小缓存的方法,最初旨在帮助开发和基准测试。
pg_stat_slru
在 PostgreSQL 13 中添加。
统计重置
可以通过执行以下命令来重置 pg_stat_slru
显示的单个或所有缓存统计信息:
SELECT pg_stat_reset_slru()
请注意,缓存名称已在 PostgreSQL 17 中更改;有关详细信息,请参阅 pg_stat_reset_slru()。
按 PostgreSQL 版本定义
pg_stat_slru (PostgreSQL 17)
View "pg_catalog.pg_stat_slru" Column | Type | Collation | Nullable | Default --------------+--------------------------+-----------+----------+--------- name | text | | | blks_zeroed | bigint | | | blks_hit | bigint | | | blks_read | bigint | | | blks_written | bigint | | | blks_exists | bigint | | | flushes | bigint | | | truncates | bigint | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_slru
pg_stat_slru (PostgreSQL 16)
View "pg_catalog.pg_stat_slru" Column | Type | Collation | Nullable | Default --------------+--------------------------+-----------+----------+--------- name | text | | | blks_zeroed | bigint | | | blks_hit | bigint | | | blks_read | bigint | | | blks_written | bigint | | | blks_exists | bigint | | | flushes | bigint | | | truncates | bigint | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_slru
pg_stat_slru (PostgreSQL 15)
View "pg_catalog.pg_stat_slru" Column | Type | Collation | Nullable | Default --------------+--------------------------+-----------+----------+--------- name | text | | | blks_zeroed | bigint | | | blks_hit | bigint | | | blks_read | bigint | | | blks_written | bigint | | | blks_exists | bigint | | | flushes | bigint | | | truncates | bigint | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_slru
pg_stat_slru (PostgreSQL 14)
View "pg_catalog.pg_stat_slru" Column | Type | Collation | Nullable | Default --------------+--------------------------+-----------+----------+--------- name | text | | | blks_zeroed | bigint | | | blks_hit | bigint | | | blks_read | bigint | | | blks_written | bigint | | | blks_exists | bigint | | | flushes | bigint | | | truncates | bigint | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_slru
pg_stat_slru (PostgreSQL 13)
View "pg_catalog.pg_stat_slru" Column | Type | Collation | Nullable | Default --------------+--------------------------+-----------+----------+--------- name | text | | | blks_zeroed | bigint | | | blks_hit | bigint | | | blks_read | bigint | | | blks_written | bigint | | | blks_exists | bigint | | | flushes | bigint | | | truncates | bigint | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_slru
更改历史记录
- PostgreSQL 17
- SLRU 缓存重命名 (提交 bcdfa5f2)
- PostgreSQL 13
- 添加 (提交 28cac71b)
示例
postgres=# SELECT * FROM pg_stat_slru; name | blks_zeroed | blks_hit | blks_read | blks_written | blks_exists | flushes | truncates | stats_reset -----------------+-------------+----------+-----------+--------------+-------------+---------+-----------+------------------------------- CommitTs | 1 | 95 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 MultiXactMember | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 MultiXactOffset | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 Notify | 1 | 5 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 Serial | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 Subtrans | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 Xact | 0 | 1131 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 other | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2021-11-03 11:08:05.213091+01 (8 rows)
参考文献
- PostgreSQL 文档: pg_stat_slru
有用链接
- CommitFest 条目: SLRU 统计