Thread
Commits
-
Fix EXPLAIN Bitmap heap scan to count pages with no visible tuples
- f3e4581acdc8 12.19 landed
- 992189a3e94d 13.15 landed
- 262757b73286 14.12 landed
- d3d95f583995 15.7 landed
- 1f4eb734200a 16.3 landed
- 0960ae1967d0 17.0 landed
-
Why does BitmapPrefetch() skip fetch based on current block recheck flag
Melanie Plageman <melanieplageman@gmail.com> — 2024-02-12T20:17:32Z
Hi, I noticed that in the following code in BitmapPrefetch(), we use the current block's TBMIterateResult->recheck when deciding whether or not to prefetch the block returned by tbm_iterate() (which is very likely a different block). Why not use TBMIterateResult->recheck for the block we are considering prefetching? I see a note that the skip fetch logic here depends on the assumption that the index AM will report the same recheck flag for this future heap page as it did for the current heap page. But why would we depend on that assumption instead of just using the TBMIterateResult just populated by tbm_iterate() for the block we are about to prefetch? That is the block we pass to PrefetchBuffer() afterward. /* * If we expect not to have to actually read this heap page, * skip this prefetch call, but continue to run the prefetch * logic normally. (Would it be better not to increment * prefetch_pages?) * * This depends on the assumption that the index AM will * report the same recheck flag for this future heap page as * it did for the current heap page; which is not a certainty * but is true in many cases. */ skip_fetch = (node->can_skip_fetch && (node->tbmres ? !node->tbmres->recheck : false) && VM_ALL_VISIBLE(node->ss.ss_currentRelation, tbmpre->blockno, &node->pvmbuffer)); if (!skip_fetch) PrefetchBuffer(scan->rs_rd, MAIN_FORKNUM, tbmpre->blockno); - Melanie