mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Delay extraction of TIDBitmap per page offsets
Pages from the bitmap created by the TIDBitmap API can be exact or lossy. The TIDBitmap API extracts the tuple offsets from exact pages into an array for the convenience of the caller. This was done in tbm_private|shared_iterate() right after advancing the iterator. However, as long as tbm_private|shared_iterate() set a reference to the PagetableEntry in the TBMIterateResult, the offset extraction can be done later. Waiting to extract the tuple offsets has a few benefits. For the shared iterator case, it allows us to extract the offsets after dropping the shared iterator state lock, reducing time spent holding a contended lock. Separating the iteration step and extracting the offsets later also allows us to avoid extracting the offsets for prefetched blocks. Those offsets were never used, so the overhead of extracting and storing them was wasted. The real motivation for this change, however, is that future commits will make bitmap heap scan use the read stream API. This requires a TBMIterateResult per issued block. By removing the array of tuple offsets from the TBMIterateResult and only extracting the offsets when they are used, we reduce the memory required for per buffer data substantially. Suggested-by: Thomas Munro <thomas.munro@gmail.com> Reviewed-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/CA%2BhUKGLHbKP3jwJ6_%2BhnGi37Pw3BD5j2amjV3oSk7j-KyCnY7Q%40mail.gmail.com
This commit is contained in:
@@ -354,6 +354,8 @@ typedef struct GinScanEntryData
|
||||
TIDBitmap *matchBitmap;
|
||||
TBMPrivateIterator *matchIterator;
|
||||
TBMIterateResult *matchResult;
|
||||
OffsetNumber matchOffsets[TBM_MAX_TUPLES_PER_PAGE];
|
||||
int matchNtuples;
|
||||
|
||||
/* used for Posting list and one page in Posting tree */
|
||||
ItemPointerData *list;
|
||||
|
||||
Reference in New Issue
Block a user