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: Fix up run-time partition pruning's use of relcache's partition
Date: Wed, 13 Jun 2018 16:03:58 +0000
Message-ID: <E1fT8Fa-0005CN-UL@gemulon.postgresql.org> (raw)

Fix up run-time partition pruning's use of relcache's partition data.

The previous coding saved pointers into the partitioned table's relcache
entry, but then closed the relcache entry, causing those pointers to
nominally become dangling.  Actual trouble would be seen in the field
only if a relcache flush occurred mid-query, but that's hardly out of
the question.

While we could fix this by copying all the data in question at query
start, it seems better to just hold the relcache entry open for the
whole query.

While at it, improve the handling of support-function lookups: do that
once per query not once per pruning test.  There's still something to be
desired here, in that we fail to exploit the possibility of caching data
across queries in the fn_extra fields of the relcache's FmgrInfo structs,
which could happen if we just used those structs in-place rather than
copying them.  However, combining that with the possibility of per-query
lookups of cross-type comparison functions seems to require changes in the
APIs of a lot of the pruning support functions, so it's too invasive to
consider as part of this patch.  A win would ensue only for complex
partition key data types (e.g. arrays), so it may not be worth the
trouble.

David Rowley and Tom Lane

Discussion: https://postgr.es/m/17850.1528755844@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/executor/execPartition.c | 63 ++++++++++++++++++++++++----------
src/backend/executor/nodeAppend.c    | 14 +++++---
src/backend/partitioning/partprune.c | 51 ++++++++++++++++++----------
src/backend/utils/cache/relcache.c   |  6 ++--
src/include/executor/execPartition.h |  5 +--
src/include/partitioning/partprune.h | 66 ++++++++++++++++++++----------------
6 files changed, 132 insertions(+), 73 deletions(-)



Message-ID: <E1fT8Fa-0005CN-UL@gemulon.postgresql.org>
Permalink:  ../E1fT8Fa-0005CN-UL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fT8Fa-0005CN-UL@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: Fix up run-time partition pruning's use of relcache's partition
  In-Reply-To: <E1fT8Fa-0005CN-UL@gemulon.postgresql.org>
  References: <E1fT8Fa-0005CN-UL@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