pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
Subject: [PATCH v4 3/6] heap pruning: Only call BufferGetBlockNumber() once.
Date: Fri, 10 Dec 2021 20:40:28 -0800

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...
---
 src/backend/access/heap/pruneheap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

inline patch 1: src/backend/access/heap/pruneheap.c (+2/-1 lines) download inline-1.patchdiff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 6557d710262..0fdc50e0599 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -270,6 +270,7 @@ heap_page_prune(Relation relation, Buffer buffer, { int ndeleted = 0; Page page = BufferGetPage(buffer); + BlockNumber blockno = BufferGetBlockNumber(buffer); OffsetNumber offnum, maxoff; PruneState prstate; @@ -337,7 +338,7 @@ heap_page_prune(Relation relation, Buffer buffer, htup = (HeapTupleHeader) PageGetItem(page, itemid); tup.t_data = htup; tup.t_len = ItemIdGetLength(itemid); - ItemPointerSet(&(tup.t_self), BufferGetBlockNumber(buffer), offnum); + ItemPointerSet(&(tup.t_self), blockno, offnum); /* * Set the offset number so that we can display it along with any -- 2.34.0
--ychkzf6m3ad4yr7p Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0004-wip-vacuum-Perform-horizon-determination-just-bef.patch"

Message-ID: <no-message-id-15985@localhost>
Permalink:  ../no-message-id-15985@localhost/
Also on:    postgresql.org/message-id/no-message-id-15985@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: andres@anarazel.de
  Subject: Re: [PATCH v4 3/6] heap pruning: Only call BufferGetBlockNumber() once.
  In-Reply-To: <no-message-id-15985@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox