Re: path toward faster partition pruning

Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>

From: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
To: Langote_Amit_f8@lab.ntt.co.jp
Cc: sulamul@gmail.com, david.rowley@2ndquadrant.com, robertmhaas@gmail.com, dilipbalaut@gmail.com, rajkumar.raghuwanshi@enterprisedb.com, memissemerson@gmail.com, pgsql-hackers@postgresql.org
Date: 2017-11-10T07:07:01Z
Lists: pgsql-hackers
Hello,

At Fri, 10 Nov 2017 14:44:55 +0900 (Tokyo Standard Time), Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> wrote in <20171110.144455.117208639.horiguchi.kyotaro@lab.ntt.co.jp>

> > Those two conditions are not orthogonal. Maybe something like
> > following seems more understantable.
> > 
> > > if (!constfalse)
> > > {
> > >   /* No constraints on the keys, so, return *all* partitions. */
> > >   if (nkeys == 0)
> > >     return bms_add_range(result, 0, partdesc->nparts - 1);
> > > 
> > >   result = get_partitions_for_keys(relation, &keys);
> > > }

So, the condition (!constfalse && nkeys == 0) cannot return
there. I'm badly confused by the variable name.

I couldn't find another reasonable structure using the current
classify_p_b_keys(), but could you add a comment like the
following as an example?

+ /*
+  * Ths function processes other than OR expressions and returns
+  * the excluded OR expressions in or_clauses
+  */
>   nkeys = classify_partition_bounding_keys(relation, clauses,
>                        &keys, &constfalse,
>                        &or_clauses);
>   /*
>    * Only look up in the partition decriptor if the query provides
>    * constraints on the keys at all.
>    */
>   if (!constfalse)
>   {
>     if (nkey > 0)
>       result = get_partitions_for_keys(relation, &keys);
>     else
-+       /* No constraints on the keys, so, all partitions are passed. */
>       result = bms_add_range(result, 0, partdesc->nparts - 1);
>   }
> 
+   /*
+    * We have a partition set for clauses not returned in or_clauses
+    * here. Conjuct the result of each OR clauses.
+    */
>   foreach(lc, or_clauses)
>   {
>     BoolExpr *or = (BoolExpr *) lfirst(lc);
>     ListCell *lc1;
>     Bitmapset *or_partset = NULL;
> 
+     Assert(or_clause(or));

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



Commits

  1. Fix assorted partition pruning bugs

  2. Make gen_partprune_steps static

  3. Remove useless 'default' clause

  4. Reorganize partitioning code

  5. Use custom hash opclass for hash partition pruning

  6. Blindly attempt to fix sepgsql tests broken due to 9fdb675fc5.

  7. Attempt to fix endianess issues in new hash partition test.

  8. Faster partition pruning

  9. For partitionwise join, match on partcollation, not parttypcoll.

  10. Revise API for partition bound search functions.

  11. Revise API for partition_rbound_cmp/partition_rbound_datum_cmp.

  12. Fix possible crash in partition-wise join.

  13. Refactor code for partition bound searching

  14. New C function: bms_add_range

  15. Add extensive tests for partition pruning.

  16. Add null test to partition constraint for default range partitions.

  17. Remove BufFile's isTemp flag.

  18. Make OWNER TO subcommand mention consistent

  19. Fix index matching for operators with mixed collatable/noncollatable inputs.