Hello,
It took me a while to figure out what those names mean. "unfetched",
as you call it on the code, may be more descriptive than "avoided" for
the new label. However I think the other two are more confusing. It
may be a good idea to change them together with this.
It'll be sad if this patch is forgotten only because of the words choice.
I've changed it all to "unfetched" for at least not to call the same
thing differently
in the code and in the output, and also rebased it and fit in 80 lines
width limit.
Best, Alex
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index d901dc4a50..c7200d2a21 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -2777,6 +2777,8 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
{
if (es->format != EXPLAIN_FORMAT_TEXT)
{
+ ExplainPropertyInteger("Unfetched Heap Blocks", NULL,
+ planstate->unfetched_pages, es);
ExplainPropertyInteger("Exact Heap Blocks", NULL,
planstate->exact_pages, es);
ExplainPropertyInteger("Lossy Heap Blocks", NULL,
@@ -2784,10 +2786,14 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
}
else
{
- if (planstate->exact_pages > 0 || planstate->lossy_pages > 0)
+ if (planstate->unfetched_pages > 0 || planstate->exact_pages > 0
+ || planstate->lossy_pages > 0)
{
ExplainIndentText(es);
appendStringInfoString(es->str, "Heap Blocks:");
+ if (planstate->unfetched_pages > 0)
+ appendStringInfo(es->str, " unfetched=%ld",
+ planstate->unfetched_pages);
if (planstate->exact_pages > 0)
appendStringInfo(es->str, " exact=%ld", planstate->exact_pages);
if (planstate->lossy_pages > 0)
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index ae8a11da30..0456f8592b 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -231,17 +231,20 @@ BitmapHeapNext(BitmapHeapScanState *node)
* node->return_empty_tuples.
*/
node->return_empty_tuples = tbmres->ntuples;
+ node->unfetched_pages++;
}
else if (!table_scan_bitmap_next_block(scan, tbmres))
{
/* AM doesn't think this block is valid, skip */
continue;
}
-
- if (tbmres->ntuples >= 0)
- node->exact_pages++;
else
- node->lossy_pages++;
+ {
+ if (tbmres->ntuples >= 0)
+ node->exact_pages++;
+ else
+ node->lossy_pages++;
+ }
/* Adjust the prefetch target */
BitmapAdjustPrefetchTarget(node);
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 5d5b38b879..0bd75c329c 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1564,6 +1564,7 @@ typedef struct ParallelBitmapHeapState
* pvmbuffer ditto, for prefetched pages
* exact_pages total number of exact pages retrieved
* lossy_pages total number of lossy pages retrieved
+ * unfetched_pages total number of pages not retrieved due to vm
* prefetch_iterator iterator for prefetching ahead of current page
* prefetch_pages # pages prefetch iterator is ahead of current
* prefetch_target current target prefetch distance
@@ -1588,6 +1589,7 @@ typedef struct BitmapHeapScanState
Buffer pvmbuffer;
long exact_pages;
long lossy_pages;
+ long unfetched_pages;
TBMIterator *prefetch_iterator;
int prefetch_pages;
int prefetch_target;