From 3bea01beb4c7c3a9376bbff194cf39dcb89f4737 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Mon, 20 Feb 2023 21:36:37 +0200 Subject: [PATCH 1/2] Fix bitmap scan prefetch --- src/backend/executor/nodeBitmapHeapscan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 8cf0ede3797..728d71d049f 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -211,6 +211,8 @@ BitmapHeapNext(BitmapHeapScanState *node) break; } + BitmapAdjustPrefetchIterator(node, tbmres); + /* * We can skip fetching the heap page if we don't need any fields * from the heap, and the bitmap entries don't need rechecking, @@ -366,7 +368,9 @@ BitmapAdjustPrefetchIterator(BitmapHeapScanState *node, { #ifdef USE_PREFETCH TBMIterator *prefetch_iterator = node->prefetch_iterator; - Assert(node->pstate == NULL); + + if (node->pstate != NULL) + return; if (node->prefetch_pages > 0) { @@ -396,6 +400,9 @@ static inline void BitmapAdjustPrefetchTarget(BitmapHeapScanState *node) { #ifdef USE_PREFETCH + if (node->pstate != NULL) + return; + if (node->prefetch_target >= node->prefetch_maximum) /* don't increase any further */ ; else if (node->prefetch_target >= node->prefetch_maximum / 2) From ad9beb8cf15b92506cc8231cdba07a91592dc4b9 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Wed, 22 Feb 2023 07:40:53 +0200 Subject: [PATCH 2/2] Add comments for changes in BitmapAdjustPrefetch* functions --- src/backend/executor/nodeBitmapHeapscan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 728d71d049f..9dcc07122d2 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -369,6 +369,7 @@ BitmapAdjustPrefetchIterator(BitmapHeapScanState *node, #ifdef USE_PREFETCH TBMIterator *prefetch_iterator = node->prefetch_iterator; + /* NEON: we are not using prefetch iterator for parallel plan so no need to adjust it */ if (node->pstate != NULL) return; @@ -400,6 +401,7 @@ static inline void BitmapAdjustPrefetchTarget(BitmapHeapScanState *node) { #ifdef USE_PREFETCH + /* NEON: we are not using prefetch iterator for parallel plan so no need to adjust it */ if (node->pstate != NULL) return;