pgsql: Improve pruning of a default partition

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve pruning of a default partition
Date: 2019-08-04 15:22:12
Message-ID: E1huIKq-00050o-QX@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Improve pruning of a default partition

When querying a partitioned table containing a default partition, we
were wrongly deciding to include it in the scan too early in the
process, failing to exclude it in some cases. If we reinterpret the
PruneStepResult.scan_default flag slightly, we can do a better job at
detecting that it can be excluded. The change is that we avoid setting
the flag for that pruning step unless the step absolutely requires the
default partition to be scanned (in contrast with the previous
arrangement, which was to set it unless the step was able to prune it).
So get_matching_partitions() must explicitly check the partition that
each returned bound value corresponds to in order to determine whether
the default one needs to be included, rather than relying on the flag
from the final step result.

Author: Yuzuko Hosoya <hosoya(dot)yuzuko(at)lab(dot)ntt(dot)co(dot)jp>
Reviewed-by: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Discussion: https://postgr.es/m/00e601d4ca86$932b8bc0$b982a340$@lab.ntt.co.jp

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/86544071484a48c753e719e0c7c9cf816a59a65e

Modified Files
--------------
src/backend/partitioning/partprune.c | 219 ++++++++++++--------------
src/include/partitioning/partbounds.h | 1 -
src/test/regress/expected/partition_prune.out | 20 ++-
src/test/regress/sql/partition_prune.sql | 1 +
4 files changed, 111 insertions(+), 130 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2019-08-04 17:07:28 pgsql: Avoid picking already-bound TCP ports in kerberos and ldap test
Previous Message Alvaro Herrera 2019-08-04 05:45:19 pgsql: Make relnote item wording consistent

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2019-08-04 15:24:39 Re: Problem with default partition pruning
Previous Message Jonathan S. Katz 2019-08-04 14:16:29 Re: First draft of back-branch release notes is done