Re: [HACKERS] why not parallel seq scan for slow functions - Mailing list pgsql-hackers
From | Amit Kapila |
---|---|
Subject | Re: [HACKERS] why not parallel seq scan for slow functions |
Date | |
Msg-id | CAA4eK1JM1bkaefanQM+macAn1Se7ALORqQRDiwaA1MpO2piLvg@mail.gmail.com Whole thread Raw |
In response to | Re: [HACKERS] why not parallel seq scan for slow functions (Robert Haas <robertmhaas@gmail.com>) |
Responses |
Re: [HACKERS] why not parallel seq scan for slow functions
|
List | pgsql-hackers |
On Thu, Mar 29, 2018 at 2:31 AM, Robert Haas <robertmhaas@gmail.com> wrote: > On Wed, Mar 28, 2018 at 3:06 AM, Amit Kapila <amit.kapila16@gmail.com> wrote: >> >> The above block takes 43700.0289 ms on Head and 45025.3779 ms with the >> patch which is approximately 3% regression. > > Thanks for the analysis -- the observation that this seemed to affect > cases where CP_LABEL_TLIST gets passed to create_projection_plan > allowed me to recognize that I was doing an unnecessary copyObject() > call. Removing that seems to have reduced this regression below 1% in > my testing. > I think that is under acceptable range. I am seeing few regression failures with the patch series. The order of targetlist seems to have changed for Remote SQL. Kindly find the failure report attached. I have requested my colleague Ashutosh Sharma to cross-verify this and he is also seeing the same failures. Few comments/suggestions: 1. typedef enum UpperRelationKind { UPPERREL_SETOP, /* result of UNION/INTERSECT/EXCEPT, if any */ + UPPERREL_TLIST, /* result of projecting final scan/join rel */ UPPERREL_PARTIAL_GROUP_AGG, /* result of partial grouping/aggregation, if * any */ UPPERREL_GROUP_AGG, /* result of grouping/aggregation, if any */ ... ... /* * Save the various upper-rel PathTargets we just computed into @@ -2003,6 +2004,7 @@ grouping_planner(PlannerInfo *root, bool inheritance_update, root->upper_targets[UPPERREL_FINAL] = final_target; root->upper_targets[UPPERREL_WINDOW] = sort_input_target; root->upper_targets[UPPERREL_GROUP_AGG] = grouping_target; + root->upper_targets[UPPERREL_TLIST] = scanjoin_target; It seems UPPERREL_TLIST is redundant in the patch now. I think we can remove it unless you have something else in mind. 2. + /* + * If the relation is partitioned, recurseively apply the same changes to + * all partitions and generate new Append paths. Since Append is not + * projection-capable, that might save a separate Result node, and it also + * is important for partitionwise aggregate. + */ + if (rel->part_scheme && rel->part_rels) { I think the handling of partitioned rels looks okay, but we might want to once check the overhead of the same unless you are sure that this shouldn't be a problem. If you think, we should check it once, then is it possible that we can do it as a separate patch as this doesn't look to be directly linked to the main patch. It can be treated as an optimization for partitionwise aggregates. I think we can treat it along with the main patch as well, but it might be somewhat simpler to verify it if we do it separately. > Also, keep in mind that we're talking about extremely small amounts of > time here. On a trivial query that you're not even executing, you're > seeing a difference of (45025.3779 - 43700.0289)/1000000 = 0.00132 ms > per execution. Sure, it's still 3%, but it's 3% of the time in an > artificial case where you don't actually run the query. In real life, > nobody runs EXPLAIN in a tight loop a million times without ever > running the query, because that's not a useful thing to do. > Agreed, but this was to ensure that we should not do this optimization at the cost of adding significant cycles to the planner time. > The > overhead on a realistic test case will be smaller. Furthermore, at > least in my testing, there are now cases where this is faster than > master. Now, I welcome further ideas for optimization, but a patch > that makes some cases slightly slower while making others slightly > faster, and also improving the quality of plans in some cases, is not > to my mind an unreasonable thing. > Agreed. -- With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com
Attachment
pgsql-hackers by date: