Postgres上idx_tup_read和idx_tup_fetch之间的区别


12

在Postgres 8.4上,当您执行以下操作时:

select * from pg_stat_all_indexes where relname = 'table_name';

它返回idx_tup_read和idx_tup_fetch字段,有什么区别?

Answers:


13

当在查看源代码看,然后你会看到,idx_tup_read在调用的结果pg_stat_get_tuples_returned(),并idx_tup_fetch为调用的结果pg_stat_get_tuples_fetched()

本手册描述了以下两个功能:

pg_stat_get_tuples_returned(oid)

当参数为表时通过顺序扫描读取的行数,或当参数为索引时返回的索引条目数

pg_stat_get_tuples_fetched(oid)

当参数为表时,通过位图扫描获取的表行数;或者当参数为索引时,通过使用索引的简单索引扫描获取的表行数


1

postgresql文档开始

idx_tup_read is number of index entries returned by scans on this index
idx_tup_fetch is number of live table rows fetched by simple index scans using this index

因此,reads是索引何时返回所需行的位置,fetches是索引何时返回表本身的行。


0

官方文档页面显示它们之间的区别出现:

  1. 当位图索引扫描中涉及索引时
  2. 如果使用索引获取了任何失效或尚未提交的行
  3. 如果通过仅索引扫描避免了堆提取
  4. 通过优化程序的检查访问索引时

在所有这些情况下,都idx_tup_read变得大于idx_tup_fetch

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.