pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make it cheap to check if a relation is modified by a query
Date: Mon, 30 Mar 2026 13:38:37 +0000
Message-ID: <E1w7CpB-0029eQ-09@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0f4c170cf3b85ef8b092990a88e5b7b50892f7d5

Modified Files
--------------
src/backend/executor/execParallel.c  |  7 +++++++
src/backend/optimizer/plan/planner.c | 15 ++++++++++++++-
src/include/nodes/plannodes.h        |  6 ++++++
3 files changed, 27 insertions(+), 1 deletion(-)



Message-ID: <E1w7CpB-0029eQ-09@gemulon.postgresql.org>
Permalink:  ../E1w7CpB-0029eQ-09@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w7CpB-0029eQ-09@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: melanieplageman@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make it cheap to check if a relation is modified by a query
  In-Reply-To: <E1w7CpB-0029eQ-09@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