Skip to content

Commit 7340d93

Browse files
committed
Widen lossy and exact page counters for Bitmap Heap Scan
Both of these counters were using the "long" data type. On MSVC that's a 32-bit type. On modern hardware, I was able to demonstrate that we can wrap those counters with a query that only takes 15 minutes to run. This issue may manifest itself either by not showing the values of the counters because they've wrapped and are less than zero, resulting in them being filtered by the > 0 checks in show_tidbitmap_info(), or bogus numbers being displayed which are modulus 2^32 of the actual number. Widen these counters to uint64. Discussion: https://postgr.es/m/CAApHDvpS_97TU+jWPc=T83WPp7vJa1dTw3mojEtAVEZOWh9bjQ@mail.gmail.com
1 parent d7db04d commit 7340d93

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/backend/commands/explain.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,10 +3635,10 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
36353635
{
36363636
if (es->format != EXPLAIN_FORMAT_TEXT)
36373637
{
3638-
ExplainPropertyInteger("Exact Heap Blocks", NULL,
3639-
planstate->exact_pages, es);
3640-
ExplainPropertyInteger("Lossy Heap Blocks", NULL,
3641-
planstate->lossy_pages, es);
3638+
ExplainPropertyUInteger("Exact Heap Blocks", NULL,
3639+
planstate->exact_pages, es);
3640+
ExplainPropertyUInteger("Lossy Heap Blocks", NULL,
3641+
planstate->lossy_pages, es);
36423642
}
36433643
else
36443644
{
@@ -3647,9 +3647,9 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
36473647
ExplainIndentText(es);
36483648
appendStringInfoString(es->str, "Heap Blocks:");
36493649
if (planstate->exact_pages > 0)
3650-
appendStringInfo(es->str, " exact=%ld", planstate->exact_pages);
3650+
appendStringInfo(es->str, " exact=" UINT64_FORMAT, planstate->exact_pages);
36513651
if (planstate->lossy_pages > 0)
3652-
appendStringInfo(es->str, " lossy=%ld", planstate->lossy_pages);
3652+
appendStringInfo(es->str, " lossy=" UINT64_FORMAT, planstate->lossy_pages);
36533653
appendStringInfoChar(es->str, '\n');
36543654
}
36553655
}

src/include/nodes/execnodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,8 @@ typedef struct BitmapHeapScanState
18171817
TBMIterator *tbmiterator;
18181818
TBMIterateResult *tbmres;
18191819
Buffer pvmbuffer;
1820-
long exact_pages;
1821-
long lossy_pages;
1820+
uint64 exact_pages;
1821+
uint64 lossy_pages;
18221822
TBMIterator *prefetch_iterator;
18231823
int prefetch_pages;
18241824
int prefetch_target;

0 commit comments

Comments
 (0)