pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid creating duplicate cached plans for inherited FK constrain
Date: Wed, 10 Mar 2021 19:22:42 +0000
Message-ID: <E1lK4Pq-0002oG-Sm@gemulon.postgresql.org> (raw)

Avoid creating duplicate cached plans for inherited FK constraints.

When a foreign key constraint is applied to a partitioned table, each
leaf partition inherits a similar FK constraint.  We were processing all
of those constraints independently, meaning that in large partitioning
trees we'd build up large collections of cached FK-checking query plans.
However, in all cases but one, the generated queries are actually
identical for all members of the inheritance tree (because, in most
cases, the query only mentions the topmost table of the other side of
the FK relationship).  So we can share a single cached plan among all
the partitions, saving memory, not to mention time to build and maintain
the cached plans.

Keisuke Kuroda and Amit Langote

Discussion: https://postgr.es/m/cab4b85d-9292-967d-adf2-be0d803c3e23@nttcom.co.jp_1

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c3ffe34863688115dd7878f118f2a123bafd8a26

Modified Files
--------------
src/backend/utils/adt/ri_triggers.c       | 67 +++++++++++++++++++++++++++++--
src/test/regress/expected/foreign_key.out | 18 +++++++++
src/test/regress/sql/foreign_key.sql      | 16 ++++++++
3 files changed, 97 insertions(+), 4 deletions(-)



Message-ID: <E1lK4Pq-0002oG-Sm@gemulon.postgresql.org>
Permalink:  ../E1lK4Pq-0002oG-Sm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lK4Pq-0002oG-Sm@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Avoid creating duplicate cached plans for inherited FK constrain
  In-Reply-To: <E1lK4Pq-0002oG-Sm@gemulon.postgresql.org>
  References: <E1lK4Pq-0002oG-Sm@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