pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Apply constraint exclusion more generally in partitioning
Date: Wed, 07 Aug 2019 16:23:06 +0000
Message-ID: <E1hvOiQ-000310-BD@gemulon.postgresql.org> (raw)

Apply constraint exclusion more generally in partitioning

We were applying constraint exclusion on the partition constraint when
generating pruning steps for a clause, but only for the rather
restricted situation of them being boolean OR operators; however it is
possible to have differently shaped clauses that also benefit from
constraint exclusion.  This applies particularly to the default
partition since their constraints are in essence a long list of OR'ed
subclauses ... but it applies to other cases too.  So in certain cases
we're scanning partitions that we don't need to.

Remove the specialized code in OR clauses, and add a generally
applicable test of the clause refuting the partition constraint; mark
the whole pruning operation as contradictory if it hits.

This has the unwanted side-effect of testing some (most? all?)
constraints more than once if constraint_exclusion=on.  That seems
unavoidable as far as I can tell without some additional work, but
that's not the recommended setting for that parameter anyway.
However, because this imposes additional processing cost for all
queries using partitioned tables, I decided not to backpatch this
change.

Author: Amit Langote, Yuzuko Hosoya, Álvaro Herrera
Reviewers: Shawn Wang, Thibaut Madeleine, Yoshikazu Imai, Kyotaro
Horiguchi; they were also uncredited reviewers for commit 489247b0e615.
Discussion: https://postgr.es/m/9bb31dfe-b0d0-53f3-3ea6-e64b811424cf@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4e85642d935eb13341584df7776eb76585d45819

Modified Files
--------------
src/backend/partitioning/partprune.c          | 56 ++++++++++++++-------------
src/test/regress/expected/partition_prune.out | 18 +++++++++
src/test/regress/sql/partition_prune.sql      |  4 ++
3 files changed, 52 insertions(+), 26 deletions(-)



Message-ID: <E1hvOiQ-000310-BD@gemulon.postgresql.org>
Permalink:  ../E1hvOiQ-000310-BD@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hvOiQ-000310-BD@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: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Apply constraint exclusion more generally in partitioning
  In-Reply-To: <E1hvOiQ-000310-BD@gemulon.postgresql.org>
  References: <E1hvOiQ-000310-BD@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