public inbox for [email protected]help / color / mirror / Atom feed
[PATCH v12 11/17] table_scan_bitmap_next_block counts lossy and exact pages 12+ messages / 2 participants [nested] [flat]
* [PATCH v12 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 38c4fd5011c..46f1a374252 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2199,7 +2199,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2349,7 +2350,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 8b6f22bc3b6..fb79f57d7a6 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -119,7 +119,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -298,14 +297,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 592a8421bdf..a06ed271eb6 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -804,8 +804,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -822,8 +822,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2019,15 +2021,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2038,7 +2042,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --6jpz2j246qmht4bt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v12-0012-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v8 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2ad785e511..266b34fe6b 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2267,7 +2268,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 7e73583fe5..96b55507a3 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -69,7 +69,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -267,14 +266,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index a820cc8c99..1d4b79a73f 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2013,15 +2015,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2032,7 +2036,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --xqq4defy3uncu6k6 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v8-0012-Separate-TBM-Shared-Iterator-and-TBMIterateResult.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v9 10/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2ad785e511..266b34fe6b 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2267,7 +2268,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 7e73583fe5..96b55507a3 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -69,7 +69,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -267,14 +266,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index a820cc8c99..1d4b79a73f 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2013,15 +2015,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2032,7 +2036,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --7mdtsjmrzitrgzgx Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9-0011-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v10 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index c76849a98e..d85fee1e50 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2264,7 +2265,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index fe471a8a0c..076e1ff674 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -119,7 +119,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -298,14 +297,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 29387166c1..edc54ecffe 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -1994,15 +1996,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2013,7 +2017,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --3o7pc6dfau5a5hry Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v10-0012-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v11 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2d9e0e1a9f..81a7488007 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2172,7 +2172,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2322,7 +2323,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index fe471a8a0c..076e1ff674 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -119,7 +119,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -298,14 +297,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 459e123e92..bb2b79717c 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -808,8 +808,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -826,8 +826,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2029,15 +2031,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2048,7 +2052,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --owzzsiozz6hgpp7e Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v11-0012-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v8 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2ad785e511..266b34fe6b 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2267,7 +2268,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 7e73583fe5..96b55507a3 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -69,7 +69,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -267,14 +266,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index a820cc8c99..1d4b79a73f 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2013,15 +2015,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2032,7 +2036,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --xqq4defy3uncu6k6 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v8-0012-Separate-TBM-Shared-Iterator-and-TBMIterateResult.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v9 10/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2ad785e511..266b34fe6b 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2267,7 +2268,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 7e73583fe5..96b55507a3 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -69,7 +69,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -267,14 +266,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index a820cc8c99..1d4b79a73f 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2013,15 +2015,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2032,7 +2036,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --7mdtsjmrzitrgzgx Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9-0011-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v8 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2ad785e511..266b34fe6b 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2267,7 +2268,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 7e73583fe5..96b55507a3 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -69,7 +69,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -267,14 +266,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index a820cc8c99..1d4b79a73f 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2013,15 +2015,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2032,7 +2036,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --xqq4defy3uncu6k6 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v8-0012-Separate-TBM-Shared-Iterator-and-TBMIterateResult.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v9 10/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2ad785e511..266b34fe6b 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2267,7 +2268,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 7e73583fe5..96b55507a3 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -69,7 +69,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -267,14 +266,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index a820cc8c99..1d4b79a73f 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2013,15 +2015,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2032,7 +2036,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --7mdtsjmrzitrgzgx Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9-0011-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v10 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index c76849a98e..d85fee1e50 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2114,7 +2114,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2264,7 +2265,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index fe471a8a0c..076e1ff674 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -119,7 +119,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -298,14 +297,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 29387166c1..edc54ecffe 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -797,8 +797,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -815,8 +815,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -1994,15 +1996,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2013,7 +2017,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --3o7pc6dfau5a5hry Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v10-0012-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* [PATCH v11 11/17] table_scan_bitmap_next_block counts lossy and exact pages @ 2024-03-22 21:09 Melanie Plageman <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Melanie Plageman @ 2024-03-22 21:09 UTC (permalink / raw) Now that the table_scan_bitmap_next_block() callback only returns false when the bitmap is exhausted, it is simpler to move the management of the lossy and exact page counters into it. We will eventually remove this callback and table_scan_bitmap_next_tuple() will update those counters when a new block is read in. --- src/backend/access/heap/heapam_handler.c | 8 ++++++-- src/backend/executor/nodeBitmapHeapscan.c | 9 ++------- src/include/access/tableam.h | 21 +++++++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2d9e0e1a9f..81a7488007 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2172,7 +2172,8 @@ heapam_estimate_rel_size(Relation rel, int32 *attr_widths, static bool heapam_scan_bitmap_next_block(TableScanDesc scan, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { HeapScanDesc hscan = (HeapScanDesc) scan; BlockNumber block; @@ -2322,7 +2323,10 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, Assert(ntup <= MaxHeapTuplesPerPage); hscan->rs_ntuples = ntup; - *lossy = tbmres->ntuples < 0; + if (tbmres->ntuples < 0) + (*lossy_pages)++; + else + (*exact_pages)++; /* * Return true to indicate that a valid block was found and the bitmap is diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index fe471a8a0c..076e1ff674 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -119,7 +119,6 @@ BitmapHeapNext(BitmapHeapScanState *node) { ExprContext *econtext; TableScanDesc scan; - bool lossy; TIDBitmap *tbm; TupleTableSlot *slot; ParallelBitmapHeapState *pstate = node->pstate; @@ -298,14 +297,10 @@ new_page: BitmapAdjustPrefetchIterator(node); - if (!table_scan_bitmap_next_block(scan, &node->recheck, &lossy, &node->blockno)) + if (!table_scan_bitmap_next_block(scan, &node->recheck, &node->blockno, + &node->lossy_pages, &node->exact_pages)) break; - if (lossy) - node->lossy_pages++; - else - node->exact_pages++; - /* * If serial, we can error out if the the prefetch block doesn't stay * ahead of the current block. diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h index 459e123e92..bb2b79717c 100644 --- a/src/include/access/tableam.h +++ b/src/include/access/tableam.h @@ -808,8 +808,8 @@ typedef struct TableAmRoutine * work to allow scan_bitmap_next_tuple() to return tuples (e.g. it might * make sense to perform tuple visibility checks at this time). * - * lossy indicates whether or not the block's representation in the bitmap - * is lossy or exact. + * lossy_pages is incremented if the block's representation in the bitmap + * is lossy, otherwise, exact_pages is incremented. * * 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 @@ -826,8 +826,10 @@ typedef struct TableAmRoutine * scan_bitmap_next_tuple need to exist, or neither. */ bool (*scan_bitmap_next_block) (TableScanDesc scan, - bool *recheck, bool *lossy, - BlockNumber *blockno); + bool *recheck, + BlockNumber *blockno, + long *lossy_pages, + long *exact_pages); /* * Fetch the next tuple of a bitmap table scan into `slot` and return true @@ -2029,15 +2031,17 @@ table_relation_estimate_size(Relation rel, int32 *attr_widths, /* * Prepare to fetch / check / return tuples as part of a bitmap table scan. * `scan` needs to have been started via table_beginscan_bm(). Returns false if - * there are no more blocks in the bitmap, true otherwise. lossy is set to true - * if bitmap is lossy for the selected block and false otherwise. + * there are no more blocks in the bitmap, true otherwise. lossy_pages is + * incremented if bitmap is lossy for the selected block and exact_pages is + * incremented otherwise. * * 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, - bool *recheck, bool *lossy, BlockNumber *blockno) + bool *recheck, BlockNumber *blockno, + long *lossy_pages, long *exact_pages) { /* * We don't expect direct calls to table_scan_bitmap_next_block with valid @@ -2048,7 +2052,8 @@ table_scan_bitmap_next_block(TableScanDesc scan, elog(ERROR, "unexpected table_scan_bitmap_next_block call during logical decoding"); return scan->rs_rd->rd_tableam->scan_bitmap_next_block(scan, recheck, - lossy, blockno); + blockno, lossy_pages, + exact_pages); } /* -- 2.40.1 --owzzsiozz6hgpp7e Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v11-0012-Hard-code-TBMIterateResult-offsets-array-size.patch" ^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Remove deprecated -H option from oid2name @ 2024-10-16 06:31 Daniel Gustafsson <[email protected]> 0 siblings, 0 replies; 12+ messages in thread From: Daniel Gustafsson @ 2024-10-16 06:31 UTC (permalink / raw) To: David G. Johnston <[email protected]>; +Cc: Nathan Bossart <[email protected]>; PostgreSQL Hackers <[email protected]> > On 16 Oct 2024, at 06:57, David G. Johnston <[email protected]> wrote: > I’m for the status-quo. We don’t imply removal when we say deprecated, only that (usually) a better alternative exists. This setup meets our existing standards. The status-quo is inconsistency, we sometimes remove features we've marked as deprecated and sometimes they are kept. -- Daniel Gustafsson ^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2024-10-16 06:31 UTC | newest] Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-03-22 21:09 [PATCH v12 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v8 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v9 10/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v8 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v10 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v10 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v11 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v11 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v9 10/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v8 11/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-03-22 21:09 [PATCH v9 10/17] table_scan_bitmap_next_block counts lossy and exact pages Melanie Plageman <[email protected]> 2024-10-16 06:31 Re: Remove deprecated -H option from oid2name Daniel Gustafsson <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox