pg_stat_get_xact_blocks_fetched()
一个返回当前事务中关系(relation)的已获取(fetched)缓冲区数量的函数。
pg_stat_get_xact_blocks_fetched() 是一个系统函数,它返回当前事务中一个表、物化视图或索引被获取的缓冲区数量。
pg_stat_get_xact_blocks_fetched() 在 PostgreSQL 7.2 中被添加。
用法
pg_stat_get_xact_blocks_fetched (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_fetched ('foo'::regclass); pg_stat_get_xact_blocks_fetched --------------------------------- 0 (1 row) postgres=# BEGIN; BEGIN postgres=*# SELECT * FROM foo LIMIT 1; id ---- 1 (1 row) postgres=*# SELECT pg_stat_get_xact_blocks_fetched ('foo'::regclass); pg_stat_get_xact_blocks_fetched --------------------------------- 1 (1 row)
参考资料
- PostgreSQL 文档: 其他统计信息函数
