pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: tableam: Perform CheckXidAlive check once per scan
Date: Thu, 29 Jan 2026 23:51:27 +0000
Message-ID: <E1vlbnK-0003nf-2n@gemulon.postgresql.org> (raw)

tableam: Perform CheckXidAlive check once per scan

Previously, the CheckXidAlive check was performed within the table_scan*next*
functions. This caused the check to be executed for every fetched tuple, an
unnecessary overhead.

To fix, move the check to table_beginscan* so it is performed once per scan
rather than once per row.

Note: table_tuple_fetch_row_version() does not use a scan descriptor;
therefore, the CheckXidAlive check is retained in that function. The overhead
is unlikely to be relevant for the existing callers.

Reported-by: Andres Freund <andres@anarazel.de>
Author: Dilip Kumar <dilipbalaut@gmail.com>
Suggested-by: Andres Freund <andres@anarazel.de>
Suggested-by: Amit Kapila <akapila@postgresql.org>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/tlpltqm5jjwj7mp66dtebwwhppe4ri36vdypux2zoczrc2i3mp%40dhv4v4nik...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/87f7b824f20c1c06884ef0711b4d32dbf4461436

Modified Files
--------------
src/backend/access/heap/heapam.c   | 10 -----
src/backend/access/index/genam.c   | 30 +++++++-------
src/backend/access/table/tableam.c | 20 +++-------
src/include/access/tableam.h       | 82 +++++++++++++++++---------------------
4 files changed, 57 insertions(+), 85 deletions(-)



Message-ID: <E1vlbnK-0003nf-2n@gemulon.postgresql.org>
Permalink:  ../E1vlbnK-0003nf-2n@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vlbnK-0003nf-2n@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: tableam: Perform CheckXidAlive check once per scan
  In-Reply-To: <E1vlbnK-0003nf-2n@gemulon.postgresql.org>

* 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