static bool
heapam_scan_bitmap_next_block(TableScanDesc scan,
- TBMIterateResult *tbmres)
+ TBMIterateResult *tbmres,
+ uint64 *lossy_pages, uint64 *exact_pages)
{
HeapScanDesc hscan = (HeapScanDesc) scan;
BlockNumber block = tbmres->blockno;
Assert(ntup <= MaxHeapTuplesPerPage);
hscan->rs_ntuples = ntup;
+ if (tbmres->ntuples >= 0)
+ (*exact_pages)++;
+ else
+ (*lossy_pages)++;
+
return ntup > 0;
}
for (;;)
{
- bool valid_block;
-
CHECK_FOR_INTERRUPTS();
/*
BitmapAdjustPrefetchIterator(node, tbmres->blockno);
- valid_block = table_scan_bitmap_next_block(scan, tbmres);
-
- if (tbmres->ntuples >= 0)
- node->stats.exact_pages++;
- else
- node->stats.lossy_pages++;
-
- if (!valid_block)
+ if (!table_scan_bitmap_next_block(scan, tbmres,
+ &node->stats.lossy_pages,
+ &node->stats.exact_pages))
{
/* AM doesn't think this block is valid, skip */
continue;
* on the page have to be returned, otherwise the tuples at offsets in
* `tbmres->offsets` need to be returned.
*
+ * `lossy_pages` and `exact_pages` are EXPLAIN counters that can be
+ * incremented by the table AM to indicate whether or not the block's
+ * representation in the bitmap is lossy.
+ *
* XXX: Currently this may only be implemented if the AM uses md.c as its
* storage manager, and uses ItemPointer->ip_blkid in a manner that maps
* blockids directly to the underlying storage. nodeBitmapHeapscan.c
* scan_bitmap_next_tuple need to exist, or neither.
*/
bool (*scan_bitmap_next_block) (TableScanDesc scan,
- struct TBMIterateResult *tbmres);
+ struct TBMIterateResult *tbmres,
+ uint64 *lossy_pages,
+ uint64 *exact_pages);
/*
* Fetch the next tuple of a bitmap table scan into `slot` and return true
* table_beginscan_bm(). Returns false if there are no tuples to be found on
* the page, true otherwise.
*
+ * `lossy_pages` and `exact_pages` are EXPLAIN counters that can be
+ * incremented by the table AM to indicate whether or not the block's
+ * representation in the bitmap is lossy.
+ *
* Note, this is an optionally implemented function, therefore should only be
* used after verifying the presence (at plan time or such).
*/
static inline bool
table_scan_bitmap_next_block(TableScanDesc scan,
- struct TBMIterateResult *tbmres)
+ struct TBMIterateResult *tbmres,
+ uint64 *lossy_pages,
+ uint64 *exact_pages)
{
/*
* We don't expect direct calls to table_scan_bitmap_next_block with valid
elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding");
return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
- tbmres);
+ tbmres,
+ lossy_pages,
+ exact_pages);
}
/*