RE: Problem with default partition pruning

Yuzuko Hosoya <hosoya.yuzuko@lab.ntt.co.jp>

From: "Yuzuko Hosoya" <hosoya.yuzuko@lab.ntt.co.jp>
To: "'Kyotaro HORIGUCHI'" <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: <Langote_Amit_f8@lab.ntt.co.jp>, <thibaut.madelaine@dalibo.com>, <imai.yoshikazu@jp.fujitsu.com>, <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-09T07:41:47Z
Lists: pgsql-hackers

Attachments

Horiguchi-san,

Thanks for your comments.

> -----Original Message-----
> From: Kyotaro HORIGUCHI [mailto:horiguchi.kyotaro@lab.ntt.co.jp]
> Sent: Tuesday, April 09, 2019 10:33 AM
> To: hosoya.yuzuko@lab.ntt.co.jp
> Cc: Langote_Amit_f8@lab.ntt.co.jp; thibaut.madelaine@dalibo.com; imai.yoshikazu@jp.fujitsu.com;
> pgsql-hackers@lists.postgresql.org
> Subject: Re: Problem with default partition pruning
> 
> Sigh..
> 
> At Tue, 09 Apr 2019 10:28:48 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI
> <horiguchi.kyotaro@lab.ntt.co.jp> wrote in
> <20190409.102848.252476604.horiguchi.kyotaro@lab.ntt.co.jp>
> > As the second thought. Partition constraint is not constraint
> > expression so that's fair to apply partqual ignoring
> > constraint_exclusion. The variable is set false to skip useless
> > expression evaluation on all partitions, but partqual should be
> > evaluated just once.  Sorry for my confusion.
> >
> > So still it is wrong that the new code is added in
> > gen_partprune_steps_internal.
> 
> So still it is wrong that the new code is added at the beginning of the loop on clauses in
> gen_partprune_steps_internal.
> 
> >                               If partqual results true and the clause
> > is long, the partqual is evaluated uselessly at every recursion.
> >
> > Maybe we should do that when we find that the current clause doesn't
> > match part attributes. Specifically just after the for loop "for (i =
> > 0 ; i < part_scheme->partnattrs; i++)".
>
I think we should check whether WHERE clause contradicts partition
constraint even when the clause matches part attributes.  So I moved
"if (partqual)" block to the beginning of the loop you mentioned. 

I'm attaching the latest version.  Could you please check it again?

Best regards,
Yuzuko Hosoya

Commits

  1. Don't constraint-exclude partitioned tables as much

  2. Apply constraint exclusion more generally in partitioning

  3. Improve pruning of a default partition

  4. Doc: Fix event trigger firing table

  5. Remove obsolete nbtree insertion comment.