Skip to content

Commit fe1431e

Browse files
committed
BitmapHeapScan: postpone setting can_skip_fetch
Set BitmapHeapScanState->can_skip_fetch in BitmapHeapNext() instead of in ExecInitBitmapHeapScan(). This is a preliminary step to pushing the skip fetch optimization into heap AM code. Author: Melanie Plageman Reviewed-by: Tomas Vondra, Andres Freund, Heikki Linnakangas Discussion: https://postgr.es/m/CAAKRu_ZwCwWFeL_H3ia26bP2e7HiKLWt0ZmGXPVwPO6uXq0vaA%40mail.gmail.com
1 parent 74eaf66 commit fe1431e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ BitmapHeapNext(BitmapHeapScanState *node)
105105
*/
106106
if (!node->initialized)
107107
{
108+
/*
109+
* We can potentially skip fetching heap pages if we do not need any
110+
* columns of the table, either for checking non-indexable quals or
111+
* for returning data. This test is a bit simplistic, as it checks
112+
* the stronger condition that there's no qual or return tlist at all.
113+
* But in most cases it's probably not worth working harder than that.
114+
*/
115+
node->can_skip_fetch = (node->ss.ps.plan->qual == NIL &&
116+
node->ss.ps.plan->targetlist == NIL);
117+
108118
if (!pstate)
109119
{
110120
tbm = (TIDBitmap *) MultiExecProcNode(outerPlanState(node));
@@ -743,16 +753,7 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
743753
scanstate->shared_tbmiterator = NULL;
744754
scanstate->shared_prefetch_iterator = NULL;
745755
scanstate->pstate = NULL;
746-
747-
/*
748-
* We can potentially skip fetching heap pages if we do not need any
749-
* columns of the table, either for checking non-indexable quals or for
750-
* returning data. This test is a bit simplistic, as it checks the
751-
* stronger condition that there's no qual or return tlist at all. But in
752-
* most cases it's probably not worth working harder than that.
753-
*/
754-
scanstate->can_skip_fetch = (node->scan.plan.qual == NIL &&
755-
node->scan.plan.targetlist == NIL);
756+
scanstate->can_skip_fetch = false;
756757

757758
/*
758759
* Miscellaneous initialization

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy