Re: speeding up planning with partitions
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
On 2019/02/21 0:50, Tom Lane wrote: > However, there are other reasons why I'm not really happy with the > approach proposed in this patch. > > The main problem is that cloning the PlannerInfo while still sharing a lot > of infrastructure between the clones is a horrid hack that I think will be > very buggy and unmaintainable. We've gotten away with it so far in > inheritance_planner because (a) the complexity is all local to that > function and (b) the cloning happens very early in the planning process, > so that there's not much shared subsidiary data to worry about; mostly > just the parse tree, which in fact isn't shared because the first thing > we do is push it through adjust_appendrel_attrs. This patch proposes > to clone much later, and both the actual cloning and the consequences > of that are spread all over, and I don't think we're nearly done with > the consequences :-(. I found the parameterized-path problem while > wondering why it was okay to not worry about adjusting attrs in data > structures used during path construction for other baserels ... turns > out it isn't. There's a lot of other stuff in PlannerInfo that you're > not touching, for instance pathkeys and placeholders; and I'm afraid > much of that represents either current bugs or future problems. > > So what I feel we should do is set this aside for now and see if we > can make something of the other idea I proposed. If we could get > rid of expand-inheritance-at-the-top altogether, and plan inherited > UPDATE/DELETE the same as inherited SELECT, that would be a large > reduction in planner complexity, hence much to be preferred over this > approach which is a large increase in planner complexity. If that > approach crashes and burns, we can come back to this. OK, I agree that the other approach might be a better way forward. It'll not just improve the performance in an elegant manner, but will also make other projects more feasible, such as, MERGE, what Fujita-san mentioned on the other thread, etc. > There might be parts of this work we can salvage, though. It seems > like the idea of postponing expand_inherited_tables() might be > something we could use anyway. +1. So, let's try to do things in this order: 1. Make inheritance-expansion-at-bottom case perform better now, addressing at least SELECT performance in PG 12, provided we manage to get the patches in order in time (I'll try to post the updated lazy-inheritance-expansion patch later this week.) 2. Overhaul inherited UPDATE/DELETE planning to use inheritance-expansion-at-bottom (PG 13) It's unfortunate that UPDATE/DELETE won't perform as well as SELECTs even couple of releases after declarative partitioning was introduced, but I agree that we should solve the underlying issues in an elegant way. Thanks, Amit
Commits
-
Clean up handling of constraint_exclusion and enable_partition_pruning.
- e03ff739695c 12.0 landed
- 11ea45ffec9a 11.3 landed
-
Add test case exercising formerly-unreached code in inheritance_planner.
- 8fba397f0ca7 12.0 landed
-
Speed up planning when partitions can be pruned at plan time.
- 428b260f87e8 12.0 landed
-
Avoid crash in partitionwise join planning under GEQO.
- 7ad6498fd5a6 12.0 landed
- d70c147fa217 11.3 landed
-
Avoid passing query tlist around separately from root->processed_tlist.
- 333ed246c6f3 12.0 landed
-
Build "other rels" of appendrel baserels in a separate step.
- 53bcf5e3dbea 12.0 landed
-
Get rid of duplicate child RTE for a partitioned table.
- e8d5dd6be79e 12.0 landed
-
Rearrange make_partitionedrel_pruneinfo to avoid work when we can't prune.
- 734308a22072 12.0 landed
-
Don't copy PartitionBoundInfo in set_relation_partition_info.
- c8151e642368 12.0 landed
-
Move building of child base quals out into a new function
- 80579f9bb171 12.0 landed
-
Reorganize planner code moved in b60c39759908
- d723f56872a9 12.0 landed
-
Move inheritance expansion code into its own file
- b60c39759908 12.0 landed
-
Fix inherited UPDATE/DELETE with UNION ALL subqueries.
- c03ad5602f52 9.4.0 cited
-
Rearrange planner to save the whole PlannerInfo (subroot) for a subquery.
- b3aaf9081a1a 9.2.0 cited