Re: Should we add GUCs to allow partition pruning to be disabled?

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Should we add GUCs to allow partition pruning to be disabled?
Date: 2018-04-23 04:46:17
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi David.

On 2018/04/21 14:09, David Rowley wrote:
> On 20 April 2018 at 20:51, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>> set constraint_exclusion to off;
>> -- not ok!
> It needed a bit more effort than I put in the first time around to
> make this work properly. constraint_exclusion = 'off' becomes a bit of
> a special case for partitioned tables now. To make this work I had to
> get rid of hasInheritedTarget and make a new enum that tracks if we're
> inheritance planning for an inheritance parent or a partitioned table.
> We can't simply only set hasInheritedTarget to true when planning with
> inheritance parents as constraint_exclusion = 'partition' must still
> know that we're planning using the inheritance planner.
> v2 patch attached.

Thanks for the updated patch.

Your proposed changes to inheritance_planner() look fine to me. In the
comment added by the patch in relation_excluded_by_constraints():

+ /*
+ * When constraint_exclusion is set to 'partition' we only handle
+ * OTHER_MEMBER_RELs, or BASERELs in cases where the result target is an
+ * inheritance parent or a partitioned table.
+ */

Just to clarify this a bit, would it be a good idea to be specific by
appending " (see inheritance_planner() where this is determined)" or some
such to this sentence?

BTW, while we're at it, would it also be a good idea to consider the patch
you had proposed, which I then posted an updated version of, to adjust the
documentation in ddl.sgml (in the section 5.10. Table Partitioning)
regarding the relationship between constraint exclusion and declarative


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-04-23 05:50:10 description of root_tuple_slot missing
Previous Message Amit Kapila 2018-04-23 04:33:43 Re: Toast issues with OldestXmin going backwards