Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1fdb0ce

Browse filesBrowse files
committed
BitmapHeapScan: Use correct recheck flag for skip_fetch
As of 7c70996, BitmapPrefetch() used the recheck flag for the current block to determine whether or not it should skip prefetching the proposed prefetch block. As explained in the comment, this assumed the index AM will report the same recheck value for the future page as it did for the current page - but there's no guarantee. This only affects prefetching - if the recheck flag changes, we may prefetch blocks unecessarily and not prefetch blocks that will be needed. But we don't need to rely on that assumption - we know the recheck flag for the block we're considering prefetching, so we can use that. The impact is very limited in practice - the opclass would need to assign different recheck flags to different blocks, but none of the built-in opclasses seems to do that. Author: Melanie Plageman Reviewed-by: Tomas Vondra, Andres Freund, Tom Lane Discussion: https://postgr.es/m/1939305.1712415547%40sss.pgh.pa.us
1 parent 04e72ed commit 1fdb0ce
Copy full SHA for 1fdb0ce

File tree

Expand file treeCollapse file tree

1 file changed

+2
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-7
lines changed

‎src/backend/executor/nodeBitmapHeapscan.c

Copy file name to clipboardExpand all lines: src/backend/executor/nodeBitmapHeapscan.c
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,9 @@ BitmapPrefetch(BitmapHeapScanState *node, TableScanDesc scan)
475475
* skip this prefetch call, but continue to run the prefetch
476476
* logic normally. (Would it be better not to increment
477477
* prefetch_pages?)
478-
*
479-
* This depends on the assumption that the index AM will
480-
* report the same recheck flag for this future heap page as
481-
* it did for the current heap page; which is not a certainty
482-
* but is true in many cases.
483478
*/
484479
skip_fetch = (!(scan->rs_flags & SO_NEED_TUPLES) &&
485-
(node->tbmres ? !node->tbmres->recheck : false) &&
480+
!tbmpre->recheck &&
486481
VM_ALL_VISIBLE(node->ss.ss_currentRelation,
487482
tbmpre->blockno,
488483
&node->pvmbuffer));
@@ -533,7 +528,7 @@ BitmapPrefetch(BitmapHeapScanState *node, TableScanDesc scan)
533528

534529
/* As above, skip prefetch if we expect not to need page */
535530
skip_fetch = (!(scan->rs_flags & SO_NEED_TUPLES) &&
536-
(node->tbmres ? !node->tbmres->recheck : false) &&
531+
!tbmpre->recheck &&
537532
VM_ALL_VISIBLE(node->ss.ss_currentRelation,
538533
tbmpre->blockno,
539534
&node->pvmbuffer));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.