mirror of
https://github.com/postgres/postgres.git
synced 2025-04-18 13:44:19 +03:00
heapam: Only set tuple's block once per page in pagemode
Due to splitting the block id into two 16 bit integers, BlockIdSet() is more expensive than one might think. Doing it once per returned tuple shows up as a small but reliably reproducible cost. It's simple enough to set the block number just once per block in pagemode, so do so. Author: Andres Freund <andres@anarazel.de> Discussion: https://www.postgresql.org/message-id/lxzj26ga6ippdeunz6kuncectr5gfuugmm2ry22qu6hcx6oid6@lzx3sjsqhmt6
This commit is contained in:
parent
af0c248557
commit
2904324a88
@ -1052,6 +1052,9 @@ heapgettup_pagemode(HeapScanDesc scan,
|
||||
linesleft = scan->rs_ntuples;
|
||||
lineindex = ScanDirectionIsForward(dir) ? 0 : linesleft - 1;
|
||||
|
||||
/* block is the same for all tuples, set it once outside the loop */
|
||||
ItemPointerSetBlockNumber(&tuple->t_self, scan->rs_cblock);
|
||||
|
||||
/* lineindex now references the next or previous visible tid */
|
||||
continue_page:
|
||||
|
||||
@ -1067,7 +1070,7 @@ continue_page:
|
||||
|
||||
tuple->t_data = (HeapTupleHeader) PageGetItem(page, lpp);
|
||||
tuple->t_len = ItemIdGetLength(lpp);
|
||||
ItemPointerSet(&(tuple->t_self), scan->rs_cblock, lineoff);
|
||||
ItemPointerSetOffsetNumber(&tuple->t_self, lineoff);
|
||||
|
||||
/* skip any tuples that don't match the scan key */
|
||||
if (key != NULL &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user