Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7bd7aa4

Browse files
Move EXPLAIN counter increment to heapam_scan_bitmap_next_block
Increment the lossy and exact page counters for EXPLAIN of bitmap heapscans in heapam_scan_bitmap_next_block(). Note that other table AMs willneed to do this as wellPushing the counters into heapam_scan_bitmap_next_block() is required tobe able to use the read stream API for bitmap heap scans. The bitmapiterator must be advanced from inside the read stream callback, soTBMIterateResults cannot be used as a flow control mechanism inBitmapHeapNext().Author: Melanie PlagemanReviewed-by: Tomas Vondra, Heikki LinnakangasDiscussion:https://postgr.es/m/063e4eb4-32d9-439e-a0b1-75565a9835a8%40iki.fi
1 parent8e7e672 commit7bd7aa4

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

‎src/backend/access/heap/heapam_handler.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths,
21152115

21162116
staticbool
21172117
heapam_scan_bitmap_next_block(TableScanDescscan,
2118-
TBMIterateResult*tbmres)
2118+
TBMIterateResult*tbmres,
2119+
uint64*lossy_pages,uint64*exact_pages)
21192120
{
21202121
HeapScanDeschscan= (HeapScanDesc)scan;
21212122
BlockNumberblock=tbmres->blockno;
@@ -2243,6 +2244,11 @@ heapam_scan_bitmap_next_block(TableScanDesc scan,
22432244
Assert(ntup <=MaxHeapTuplesPerPage);
22442245
hscan->rs_ntuples=ntup;
22452246

2247+
if (tbmres->ntuples >=0)
2248+
(*exact_pages)++;
2249+
else
2250+
(*lossy_pages)++;
2251+
22462252
returnntup>0;
22472253
}
22482254

‎src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ BitmapHeapNext(BitmapHeapScanState *node)
212212

213213
for (;;)
214214
{
215-
boolvalid_block;
216-
217215
CHECK_FOR_INTERRUPTS();
218216

219217
/*
@@ -233,14 +231,9 @@ BitmapHeapNext(BitmapHeapScanState *node)
233231

234232
BitmapAdjustPrefetchIterator(node,tbmres->blockno);
235233

236-
valid_block=table_scan_bitmap_next_block(scan,tbmres);
237-
238-
if (tbmres->ntuples >=0)
239-
node->stats.exact_pages++;
240-
else
241-
node->stats.lossy_pages++;
242-
243-
if (!valid_block)
234+
if (!table_scan_bitmap_next_block(scan,tbmres,
235+
&node->stats.lossy_pages,
236+
&node->stats.exact_pages))
244237
{
245238
/* AM doesn't think this block is valid, skip */
246239
continue;

‎src/include/access/tableam.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,10 @@ typedef struct TableAmRoutine
796796
* on the page have to be returned, otherwise the tuples at offsets in
797797
* `tbmres->offsets` need to be returned.
798798
*
799+
* `lossy_pages` and `exact_pages` are EXPLAIN counters that can be
800+
* incremented by the table AM to indicate whether or not the block's
801+
* representation in the bitmap is lossy.
802+
*
799803
* XXX: Currently this may only be implemented if the AM uses md.c as its
800804
* storage manager, and uses ItemPointer->ip_blkid in a manner that maps
801805
* blockids directly to the underlying storage. nodeBitmapHeapscan.c
@@ -811,7 +815,9 @@ typedef struct TableAmRoutine
811815
* scan_bitmap_next_tuple need to exist, or neither.
812816
*/
813817
bool(*scan_bitmap_next_block) (TableScanDescscan,
814-
structTBMIterateResult*tbmres);
818+
structTBMIterateResult*tbmres,
819+
uint64*lossy_pages,
820+
uint64*exact_pages);
815821

816822
/*
817823
* Fetch the next tuple of a bitmap table scan into `slot` and return true
@@ -1954,12 +1960,18 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths,
19541960
* table_beginscan_bm(). Returns false if there are no tuples to be found on
19551961
* the page, true otherwise.
19561962
*
1963+
* `lossy_pages` and `exact_pages` are EXPLAIN counters that can be
1964+
* incremented by the table AM to indicate whether or not the block's
1965+
* representation in the bitmap is lossy.
1966+
*
19571967
* Note, this is an optionally implemented function, therefore should only be
19581968
* used after verifying the presence (at plan time or such).
19591969
*/
19601970
staticinlinebool
19611971
table_scan_bitmap_next_block(TableScanDescscan,
1962-
structTBMIterateResult*tbmres)
1972+
structTBMIterateResult*tbmres,
1973+
uint64*lossy_pages,
1974+
uint64*exact_pages)
19631975
{
19641976
/*
19651977
* We don't expect direct calls to table_scan_bitmap_next_block with valid
@@ -1970,7 +1982,9 @@ table_scan_bitmap_next_block(TableScanDesc scan,
19701982
elog(ERROR,"unexpected table_scan_bitmap_next_block call during logical decoding");
19711983

19721984
returnscan->rs_rd->rd_tableam->scan_bitmap_next_block(scan,
1973-
tbmres);
1985+
tbmres,
1986+
lossy_pages,
1987+
exact_pages);
19741988
}
19751989

19761990
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp