]> git.ipfire.org Git - thirdparty/postgresql.git/commit
tableam: Perform CheckXidAlive check once per scan
authorAndres Freund <andres@anarazel.de>
Thu, 29 Jan 2026 22:27:23 +0000 (17:27 -0500)
committerAndres Freund <andres@anarazel.de>
Thu, 29 Jan 2026 22:52:07 +0000 (17:52 -0500)
commit87f7b824f20c1c06884ef0711b4d32dbf4461436
treef44fbf3767e73c6da26fe21fa878da2b9bfbfb1f
parent333f586372aae764b7ad7e2c975b14fd431ce819
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%40dhv4v4nikyfg
src/backend/access/heap/heapam.c
src/backend/access/index/genam.c
src/backend/access/table/tableam.c
src/include/access/tableam.h