Re: path toward faster partition pruning
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
On 2017/09/08 4:41, Robert Haas wrote: > On Thu, Sep 7, 2017 at 7:16 AM, Amit Langote > <Langote_Amit_f8@lab.ntt.co.jp> wrote: >> There is a patch in the Ashutosh's posted series of patches, which does >> more or less the same thing that this patch does. He included it in his >> series of patches, because, IIUC, the main partitionwise-join planning >> logic that one of the later patch implements depends on being able to >> consider applying that new planning technique individually for every >> partition sub-tree, instead of just at the whole tree root. >> >> One notable difference from his patch is that while his patch will expand >> in non-flattened manner even in the case where the parent is the result >> relation of a query, my patch doesn't in that case, because the new >> partition-pruning technique cannot be applied to inheritance parent that >> is a result relation, for example, >> >> update partitioned_table set ... >> >> And AFAICS, partitionwise-join cannot be applied to such a parent either. >> >> Note however that if there are other instances of the same partitioned >> table (in the FROM list of an update statement) or other partitioned >> tables in the query, they will be expanded in a non-flattened manner, >> because they are themselves not the result relations of the query. So, >> the new partition-pruning and (supposedly) partitionwise-join can be >> applied for those other partitioned tables. > > It seems to me that it would be better not to write new patches for > things that already have patches without a really clear explanation > with what's wrong with the already-existing patch; I don't see any > such explanation here. Instead of writing your own patch for this to > duel with his his, why not review his and help him correct any > deficiencies which you can spot? Then we have one patch with more > review instead of two patches with less review both of which I have to > read and try to decide which is better. Sorry, I think I should have just used the Ashutosh's patch. > In this case, I think Ashutosh has the right idea. I think that > handling the result-relation and non-result-relation differently > creates an unpleasant asymmetry. With your patch, we have to deal > with three cases: (a) partitioned tables that were expanded > level-by-level because they are not result relations, (b) partitioned > tables that were expanded "flattened" because they are result > relations, and (c) non-partitioned tables that were expanded > "flattened". With Ashutosh's approach, we only have two cases to > worry about in the future rather than three, and I like that better. I tend to agree with this now. > Your patch also appears to change things so that the table actually > referenced in the query ends up with an AppendRelInfo for the parent, > which seems pointless. Actually, it wouldn't, because my patch also got rid of the notion of adding the duplicate RTE for original parent, because I thought the duplicate RTE was pointless in the partitioning case. > There are a couple of hunks from your patch that we might want or need > to incorporate into Ashutosh's patch. The change to > relation_excluded_by_constraints() looks like it might be useful, > although it needs a better comment and some tests. I think we could just drop that part from this patch. It also looks like Ashutosh has a patch elsewhere concerning this. https://commitfest.postgresql.org/14/1108/ Maybe, we could discuss what do about this on that thread. Now that not only the root partitioned table, but also other partitioned tables in the tree get an RTE with inh = true, I think it would be interesting to consider his patch. > Also, Ashutosh's > patch has no equivalent of your change to add_paths_to_append_rel(). > I'm not clear what the code you've introduced there is supposed to be > doing, and I'm suspicious that it is confusing "partition root" with > "table named in the query", which will often be the same but not > always; the user could have named an intermediate partition. Can you > expand on what this is doing? I've replied on the partition-wise thread explaining why changes in the add_paths_to_append_rel() are necessary. Anyway, I'm dropping my patch in favor of the patch on the other thread. Sorry for the duplicated effort involved in having to look at both the patches. Thanks, Amit [1] https://www.postgresql.org/message-id/CA%2BTgmoZEUonD9dUZH1FBEyq%3DPEv_KvE3wC%3DA%3D0zm-_tRz_917A%40mail.gmail.com
Commits
-
Fix assorted partition pruning bugs
- d758d9702e2f 11.0 landed
-
Make gen_partprune_steps static
- d1e2cac5ff7e 11.0 landed
-
Remove useless 'default' clause
- c775fb9e18ac 11.0 landed
-
Reorganize partitioning code
- da6f3e45ddb6 11.0 landed
-
Use custom hash opclass for hash partition pruning
- fafec4cce814 11.0 landed
-
Blindly attempt to fix sepgsql tests broken due to 9fdb675fc5.
- 4f813c7203e0 11.0 landed
-
Attempt to fix endianess issues in new hash partition test.
- 40e42e1024c5 11.0 landed
-
Faster partition pruning
- 9fdb675fc5d2 11.0 landed
-
For partitionwise join, match on partcollation, not parttypcoll.
- 2af28e603319 11.0 landed
-
Revise API for partition bound search functions.
- f724022d0ae0 11.0 landed
-
Revise API for partition_rbound_cmp/partition_rbound_datum_cmp.
- b0229235564f 11.0 landed
-
Fix possible crash in partition-wise join.
- f069c91a5793 11.0 cited
-
Refactor code for partition bound searching
- 9aef173163ae 11.0 landed
-
New C function: bms_add_range
- 84940644de93 11.0 landed
-
Add extensive tests for partition pruning.
- 8d4e70a63bf8 11.0 landed
-
Add null test to partition constraint for default range partitions.
- 7b88d63a9122 11.0 cited
-
Remove BufFile's isTemp flag.
- 11e264517dff 11.0 cited
-
Make OWNER TO subcommand mention consistent
- bf54c0f05c0a 11.0 cited
-
Fix index matching for operators with mixed collatable/noncollatable inputs.
- cb37c291060d 9.2.0 cited