pg_stat_get_xact_blocks_hit() 是一个系统函数,用于返回当前事务中表、物化视图或索引的缓存命中数。
pg_stat_get_xact_blocks_hit() 添加于 PostgreSQL 7.2。
用法
pg_stat_get_xact_blocks_hit (oid) →bigint
如果指定的关系不是表、物化视图或索引,则返回 0。
如果指定的关系不存在,则会引发一个 ERROR 错误。
变更历史
- PostgreSQL 7.2
- 添加(提交 140ddb78)
示例
pg_stat_get_xact_blocks_fetched() 的基本用法示例
postgres=# CREATE TABLE foo (id INT NOT NULL PRIMARY KEY); CREATE TABLE postgres=# INSERT INTO foo VALUES(generate_series(1,100)); INSERT 0 100 postgres=# SELECT * FROM foo LIMIT 1; id ---- 1 (1 row) postgres=# SELECT pg_stat_get_xact_blocks_hit ('foo'::regclass); pg_stat_get_xact_blocks_hit ----------------------------- 0 (1 row) postgres=# BEGIN; BEGIN postgres=*# SELECT * FROM foo LIMIT 1; id ---- 1 (1 row) postgres=*# SELECT pg_stat_get_xact_blocks_hit ('foo'::regclass); pg_stat_get_xact_blocks_hit ----------------------------- 1 (1 row)
参考资料
- PostgreSQL 文档: 其他统计信息函数
