Skip to content

Commit c702d65

Browse files
committed
heap pruning: Only call BufferGetBlockNumber() once.
BufferGetBlockNumber() is not that cheap and obviously cannot change during one heap_prune_page(), so only call it once. We might be able to do better and pass the block number from the caller, but that'd be a larger change... Discussion: https://postgr.es/m/20211211045710.ljtuu4gfloh754rs@alap3.anarazel.de
1 parent 35b2803 commit c702d65

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/access/heap/pruneheap.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ heap_page_prune(Relation relation, Buffer buffer,
269269
{
270270
int ndeleted = 0;
271271
Page page = BufferGetPage(buffer);
272+
BlockNumber blockno = BufferGetBlockNumber(buffer);
272273
OffsetNumber offnum,
273274
maxoff;
274275
PruneState prstate;
@@ -335,7 +336,7 @@ heap_page_prune(Relation relation, Buffer buffer,
335336
htup = (HeapTupleHeader) PageGetItem(page, itemid);
336337
tup.t_data = htup;
337338
tup.t_len = ItemIdGetLength(itemid);
338-
ItemPointerSet(&(tup.t_self), BufferGetBlockNumber(buffer), offnum);
339+
ItemPointerSet(&(tup.t_self), blockno, offnum);
339340

340341
/*
341342
* Set the offset number so that we can display it along with any

0 commit comments

Comments
 (0)