1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-21 15:54:08 +03:00

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
This commit is contained in:
David Rowley 2024-07-08 14:43:09 +12:00
parent d7db04dfda
commit 7340d9362a
2 changed files with 8 additions and 8 deletions

View File

@ -3635,9 +3635,9 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
{ {
if (es->format != EXPLAIN_FORMAT_TEXT) if (es->format != EXPLAIN_FORMAT_TEXT)
{ {
ExplainPropertyInteger("Exact Heap Blocks", NULL, ExplainPropertyUInteger("Exact Heap Blocks", NULL,
planstate->exact_pages, es); planstate->exact_pages, es);
ExplainPropertyInteger("Lossy Heap Blocks", NULL, ExplainPropertyUInteger("Lossy Heap Blocks", NULL,
planstate->lossy_pages, es); planstate->lossy_pages, es);
} }
else else
@ -3647,9 +3647,9 @@ show_tidbitmap_info(BitmapHeapScanState *planstate, ExplainState *es)
ExplainIndentText(es); ExplainIndentText(es);
appendStringInfoString(es->str, "Heap Blocks:"); appendStringInfoString(es->str, "Heap Blocks:");
if (planstate->exact_pages > 0) if (planstate->exact_pages > 0)
appendStringInfo(es->str, " exact=%ld", planstate->exact_pages); appendStringInfo(es->str, " exact=" UINT64_FORMAT, planstate->exact_pages);
if (planstate->lossy_pages > 0) if (planstate->lossy_pages > 0)
appendStringInfo(es->str, " lossy=%ld", planstate->lossy_pages); appendStringInfo(es->str, " lossy=" UINT64_FORMAT, planstate->lossy_pages);
appendStringInfoChar(es->str, '\n'); appendStringInfoChar(es->str, '\n');
} }
} }

View File

@ -1817,8 +1817,8 @@ typedef struct BitmapHeapScanState
TBMIterator *tbmiterator; TBMIterator *tbmiterator;
TBMIterateResult *tbmres; TBMIterateResult *tbmres;
Buffer pvmbuffer; Buffer pvmbuffer;
long exact_pages; uint64 exact_pages;
long lossy_pages; uint64 lossy_pages;
TBMIterator *prefetch_iterator; TBMIterator *prefetch_iterator;
int prefetch_pages; int prefetch_pages;
int prefetch_target; int prefetch_target;