On Fri, Mar 23, 2018 at 12:12 AM, Amit Kapila <amit.kapil...@gmail.com> wrote: > Yeah, sometimes that kind of stuff change performance characteristics, > but I think what is going on here is that create_projection_plan is > causing the lower node to build physical tlist which takes some > additional time. I have tried below change on top of the patch series > and it brings back the performance for me.
I tried another approach inspired by this, which is to altogether skip building the child scan tlist if it will just be replaced. See 0006. In testing here, that seems to be a bit better than your proposal, but I wonder what your results will be. > Before returning subplan, don't we need to copy the cost estimates > from best_path as is done in the same function after few lines. The new 0006 takes care of this, too. Really, the new 0006 should be merged into 0001, but I kept it separate for now. So, rebased: 0001 - More or less as before. 0002 - More or less as before. 0003 - Rewritten in the wake of partitionwise aggregate, as the tlist_rel must be partitioned in order for partitionwise aggregate to work. Quite pleasingly, this eliminates a bunch of Result nodes from the partitionwise join test results. Overall, I find this quite a bit cleaner than the present code (leaving performance aside for the moment). In the process of writing this I realized that the partitionwise aggregate code doesn't look like it handles SRFs properly, so if this doesn't get committed we'll have to fix that problem some other way. 0004 - A little different than before as a result of the extensive changes in 0003. 0005 - Also different, and revealing another defect in partitionwise aggregate, as noted in the commit message. 0006 - Introduce CP_IGNORE_TLIST; optimization of 0001. 0007 - Use NULL relids set for the toplevel tlist upper rel. This seems to be slightly faster than the other way. This is an optimization of 0003. It looks in my testing like this still underperforms master on your test case. Do you get the same result? Any other ideas? -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
0007-Use-NULL-relids-set.patch
Description: Binary data
0006-CP_IGNORE_TLIST.patch
Description: Binary data
0005-Remove-explicit-path-construction-logic-in-create_or.patch
Description: Binary data
0004-Postpone-generate_gather_paths-for-topmost-scan-join.patch
Description: Binary data
0003-Add-new-upper-rel-to-represent-projecting-toplevel-s.patch
Description: Binary data
0002-Adjust-use_physical_tlist-to-work-on-upper-rels.patch
Description: Binary data
0001-Teach-create_projection_plan-to-omit-projection-wher.patch
Description: Binary data