]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Make it cheap to check if a relation is modified by a query
authorMelanie Plageman <melanieplageman@gmail.com>
Mon, 30 Mar 2026 13:38:03 +0000 (09:38 -0400)
committerMelanie Plageman <melanieplageman@gmail.com>
Mon, 30 Mar 2026 13:38:03 +0000 (09:38 -0400)
commit0f4c170cf3b85ef8b092990a88e5b7b50892f7d5
tree149f630877b006fa761906efe5efc2f37b57eedf
parent1bd6f22f43ac1bd2215ba4ef720fc4f18fea26e5
Make it cheap to check if a relation is modified by a query

Save the range table indexes of result relations and row mark relations
in separate bitmapsets in the PlannedStmt. Precomputing them allows
cheap membership checks during execution. Together, these two groups
approximate all relations that will be modified by a query. This
includes relations targeted by INSERT, UPDATE, DELETE, and MERGE as well
as relations with any row mark (like SELECT FOR UPDATE).

Future work will use information on whether or not a relation is
modified by a query in a heuristic.

PlannedStmt->resultRelations is only used in a membership check, so it
will be removed in a separate commit.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/F5CDD1B5-628C-44A1-9F85-3958C626F6A9%40gmail.com
src/backend/executor/execParallel.c
src/backend/optimizer/plan/planner.c
src/include/nodes/plannodes.h