Re: [HACKERS] Partition-wise aggregation/grouping

2019-07-04 Thread Andrey Lepikhov
> Regarding apply_scanjoin_target_to_paths in 0001 and 0007, it seems > like what happens is: we first build an Append path for the topmost > scan/join rel. That uses paths from the individual relations that > don't necessarily produce the final scan/join target. Then we mutate > those relations

Re: [HACKERS] Partition-wise aggregation/grouping

2018-04-10 Thread Jeevan Chalke
On Tue, Apr 10, 2018 at 7:30 PM, David Steele wrote: > Hi Jeevan, > > On 4/2/18 10:57 AM, Robert Haas wrote: > > On Thu, Mar 29, 2018 at 9:02 AM, Jeevan Chalke > > wrote: > >> Yep, I see the risk. > > > > Committed 0001 last week and 0002 just now. I don't really see 0003 a > > a critical need.

Re: [HACKERS] Partition-wise aggregation/grouping

2018-04-10 Thread David Steele
Hi Jeevan, On 4/2/18 10:57 AM, Robert Haas wrote: > On Thu, Mar 29, 2018 at 9:02 AM, Jeevan Chalke > wrote: >> Yep, I see the risk. > > Committed 0001 last week and 0002 just now. I don't really see 0003 a > a critical need. If somebody demonstrates that this saves a > meaningful amount of pla

Re: [HACKERS] Partition-wise aggregation/grouping

2018-04-02 Thread Robert Haas
On Thu, Mar 29, 2018 at 9:02 AM, Jeevan Chalke wrote: > Yep, I see the risk. Committed 0001 last week and 0002 just now. I don't really see 0003 a a critical need. If somebody demonstrates that this saves a meaningful amount of planning time, we can consider that part for a future release. --

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-29 Thread Jeevan Chalke
On Thu, Mar 29, 2018 at 4:13 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Wed, Mar 28, 2018 at 7:21 PM, Ashutosh Bapat > wrote: > > > > Ah sorry, I was wrong about remote_conds. remote_conds and local_conds > > are basically the conditions on the relation being pushed down. >

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-29 Thread Jeevan Chalke
On Wed, Mar 28, 2018 at 7:21 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Tue, Mar 27, 2018 at 2:43 PM, Jeevan Chalke > wrote: > > > I am not sure on what we should Assetrt here. Note that we end-up here > only > > when doing grouping, and thus I don't think we need any Asser

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-29 Thread Ashutosh Bapat
On Wed, Mar 28, 2018 at 7:21 PM, Ashutosh Bapat wrote: > > Ah sorry, I was wrong about remote_conds. remote_conds and local_conds > are basically the conditions on the relation being pushed down. > havingQuals are conditions on a grouped relation so treating them like > baserestrictinfo or join co

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-28 Thread Ashutosh Bapat
On Tue, Mar 27, 2018 at 2:43 PM, Jeevan Chalke wrote: >> else if (IS_UPPER_REL(foreignrel)) >> { >> PgFdwRelationInfo *ofpinfo; >> -PathTarget *ptarget = >> root->upper_targets[UPPERREL_GROUP_AGG]; >> +PathTarget *ptarget = fpinfo->grouped_ta

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-27 Thread Jeevan Chalke
On Mon, Mar 26, 2018 at 5:24 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Fri, Mar 23, 2018 at 4:35 PM, Jeevan Chalke > wrote: > > > > Changes related to postgres_fdw which allows pushing aggregate on the > > foreign server is not yet committed. Due to this, we will end up ge

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-26 Thread Jeevan Chalke
On Tue, Mar 27, 2018 at 3:33 AM, Andres Freund wrote: > Hi, > > On 2018-03-23 17:01:54 +0530, Jeevan Chalke wrote: > > Attached patch which fixes that. > > Thanks, will push. For the future, I'd be more likely to notice if you > CC me ;) > Sure. Thanks. > > > > However, I am not sure whether i

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-26 Thread Andres Freund
Hi, On 2018-03-23 17:01:54 +0530, Jeevan Chalke wrote: > Attached patch which fixes that. Thanks, will push. For the future, I'd be more likely to notice if you CC me ;) > However, I am not sure whether it is expected to have stable regression run > with installcheck having local settings. > Fo

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-26 Thread Ashutosh Bapat
On Fri, Mar 23, 2018 at 4:35 PM, Jeevan Chalke wrote: > > Changes related to postgres_fdw which allows pushing aggregate on the > foreign server is not yet committed. Due to this, we will end up getting an > error when we have foreign partitions + aggregation. > > Attached 0001 patch here (0006 fr

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-23 Thread Jeevan Chalke
Hi Robert, On pgsql-committers Andres reported one concern about test case failure with installcheck with local settings. (Sorry, I have not subscribed to that mailing list and thus not able to reply there). Attached patch which fixes that. However, I am not sure whether it is expected to have s

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-23 Thread Jeevan Chalke
On Thu, Mar 22, 2018 at 10:28 PM, Robert Haas wrote: > On Thu, Mar 22, 2018 at 6:15 AM, Jeevan Chalke > wrote: > > Leeks cleaner now. Thanks for refactoring it. > > > > I have merged these changes and flatten all previuos changes into the > main > > patch. > > Committed 0001-0005. Thanks Rober

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-22 Thread Robert Haas
On Thu, Mar 22, 2018 at 6:15 AM, Jeevan Chalke wrote: > Leeks cleaner now. Thanks for refactoring it. > > I have merged these changes and flatten all previuos changes into the main > patch. Committed 0001-0005. I made a few further modifications. These were mostly cosmetic, but with two excepti

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-22 Thread Jeevan Chalke
On Thu, Mar 22, 2018 at 10:06 AM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Thu, Mar 22, 2018 at 3:26 AM, Robert Haas > wrote: > > > > Is there a good reason not to use input_rel->relids as the input to > > fetch_upper_rel() in all cases, rather than just at subordinate > > le

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-22 Thread Jeevan Chalke
On Thu, Mar 22, 2018 at 3:26 AM, Robert Haas wrote: > On Wed, Mar 21, 2018 at 11:33 AM, Jeevan Chalke > wrote: > > Let me try to explain this: > > 1. GROUPING_CAN_PARTITIONWISE_AGG > > 2. extra->is_partial_aggregation > > 3. extra->perform_partial_partitionwise_aggregation > > Please find attach

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-21 Thread Ashutosh Bapat
On Thu, Mar 22, 2018 at 3:26 AM, Robert Haas wrote: > > Is there a good reason not to use input_rel->relids as the input to > fetch_upper_rel() in all cases, rather than just at subordinate > levels? > That would simplify some code in these patches. We have set upper_rel->relids to NULL for non-o

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-21 Thread Robert Haas
On Wed, Mar 21, 2018 at 11:33 AM, Jeevan Chalke wrote: > Let me try to explain this: > 1. GROUPING_CAN_PARTITIONWISE_AGG > 2. extra->is_partial_aggregation > 3. extra->perform_partial_partitionwise_aggregation Please find attached an incremental patch that attempts to refactor this logic into a s

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-21 Thread Jeevan Chalke
On Wed, Mar 21, 2018 at 7:46 PM, Robert Haas wrote: > On Wed, Mar 21, 2018 at 8:01 AM, Jeevan Chalke > wrote: > >> In the patch as proposed, create_partial_grouping_paths() can get > >> called even if GROUPING_CAN_PARTIAL_AGG is not set. I think that's > >> wrong. > > > > I don't think so. For

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-21 Thread Robert Haas
On Wed, Mar 21, 2018 at 8:01 AM, Jeevan Chalke wrote: >> In the patch as proposed, create_partial_grouping_paths() can get >> called even if GROUPING_CAN_PARTIAL_AGG is not set. I think that's >> wrong. > > I don't think so. For parallel case, we do check that. And for partitionwise > aggregation

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-21 Thread Jeevan Chalke
On Wed, Mar 21, 2018 at 2:04 AM, Robert Haas wrote: > On Tue, Mar 20, 2018 at 10:46 AM, Jeevan Chalke > wrote: > > I have added all these three patches in the attached patch-set and > rebased > > my changes over it. > > > > However, I have not yet made this patch-set dependednt on UPPERREL_TLIST

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-20 Thread Robert Haas
On Tue, Mar 20, 2018 at 10:46 AM, Jeevan Chalke wrote: > I have added all these three patches in the attached patch-set and rebased > my changes over it. > > However, I have not yet made this patch-set dependednt on UPPERREL_TLIST > changes you have proposed on another mail-thread and thus it has

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-20 Thread Jeevan Chalke
Hi, On Mon, Mar 19, 2018 at 10:56 PM, Robert Haas wrote: > On Fri, Mar 16, 2018 at 1:50 PM, Ashutosh Bapat > wrote: > > Ok. That looks good. > > Here's an updated version. In this version, based on a voice > discussion with Ashutosh and Jeevan, I adjusted 0001 to combine it > with an earlier i

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-19 Thread Ashutosh Bapat
On Mon, Mar 19, 2018 at 11:15 PM, Robert Haas wrote: > On Fri, Mar 16, 2018 at 1:50 PM, Ashutosh Bapat > wrote: >>> This patch also renames can_parallel_agg to >>> can_partial_agg and removes the parallelism-specific bits from it. >> >> I think we need to update the comments in this function to u

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-19 Thread Robert Haas
On Fri, Mar 16, 2018 at 1:50 PM, Ashutosh Bapat wrote: >> This patch also renames can_parallel_agg to >> can_partial_agg and removes the parallelism-specific bits from it. > > I think we need to update the comments in this function to use phrase > "partial aggregation" instead of "parallel aggrega

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-19 Thread Robert Haas
On Fri, Mar 16, 2018 at 1:50 PM, Ashutosh Bapat wrote: > Ok. That looks good. Here's an updated version. In this version, based on a voice discussion with Ashutosh and Jeevan, I adjusted 0001 to combine it with an earlier idea of splitting Gather/Gather Merge path generation out of the function

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-16 Thread Ashutosh Bapat
On Fri, Mar 16, 2018 at 3:19 AM, Robert Haas wrote: > On Thu, Mar 15, 2018 at 2:46 PM, Robert Haas wrote: >> I wonder if we could simplify things by copying more information from >> the parent grouping rel to the child grouping rels. > > On further review, it seems like a better idea is to genera

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-16 Thread Ashutosh Bapat
On Fri, Mar 16, 2018 at 12:16 AM, Robert Haas wrote: > > - partial_costs_set. The comment in compute_group_path_extra_data > doesn't look good. It says "Set partial aggregation costs if we are > going to calculate partial aggregates in make_grouping_rels()", but > what it means is something more

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-16 Thread Ashutosh Bapat
On Thu, Mar 15, 2018 at 9:19 PM, Robert Haas wrote: > On Thu, Mar 15, 2018 at 9:46 AM, Jeevan Chalke > wrote: >> Hmm.. you are right. Done. > > I don't see a reason to hold off on committing 0002 and 0003, so I've > done that now; since they are closely related changes, I pushed them > as a singl

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-16 Thread Ashutosh Bapat
On Thu, Mar 15, 2018 at 7:46 PM, Robert Haas wrote: > On Thu, Mar 15, 2018 at 6:08 AM, Ashutosh Bapat > wrote: >> In current create_grouping_paths() (without any of your patches >> applied) we first create partial paths in partially grouped rel and >> then add parallel path to grouped rel using t

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-15 Thread Robert Haas
On Thu, Mar 15, 2018 at 2:46 PM, Robert Haas wrote: > I wonder if we could simplify things by copying more information from > the parent grouping rel to the child grouping rels. On further review, it seems like a better idea is to generate the partial grouping relations from the grouping relation

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-15 Thread Robert Haas
On Thu, Mar 15, 2018 at 11:49 AM, Robert Haas wrote: > I'm going to go spend some time looking at 0005 next. It looks to me > like it's generally going in a very promising direction, but I need to > study the details more. On further study this patch is doing a number of things, some of which se

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-15 Thread Robert Haas
On Thu, Mar 15, 2018 at 9:46 AM, Jeevan Chalke wrote: > Hmm.. you are right. Done. I don't see a reason to hold off on committing 0002 and 0003, so I've done that now; since they are closely related changes, I pushed them as a single commit. It probably could've just been included in the main pa

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-15 Thread Robert Haas
On Thu, Mar 15, 2018 at 6:08 AM, Ashutosh Bapat wrote: > In current create_grouping_paths() (without any of your patches > applied) we first create partial paths in partially grouped rel and > then add parallel path to grouped rel using those partial paths. Then > we hand over this to FDW and exte

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-15 Thread Jeevan Chalke
On Thu, Mar 15, 2018 at 3:38 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > > The patchset needs rebase. I have rebased those on the latest head > and made following changes. > > Argument force_partial_agg is added after output arguments to > make_grouping_rels(). Moved it before

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-15 Thread Ashutosh Bapat
On Wed, Mar 14, 2018 at 7:51 PM, Jeevan Chalke wrote: > > > On Tue, Mar 13, 2018 at 7:43 PM, Jeevan Chalke > wrote: >> >> Hi, >> >> The patch-set is complete now. But still, there is a scope of some comment >> improvements due to all these refactorings. I will work on it. Also, need to >> update

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-14 Thread Jeevan Chalke
On Tue, Mar 13, 2018 at 7:43 PM, Jeevan Chalke < jeevan.cha...@enterprisedb.com> wrote: > Hi, > > The patch-set is complete now. But still, there is a scope of some comment > improvements due to all these refactorings. I will work on it. Also, need > to update few documentations and indentations e

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-13 Thread Jeevan Chalke
Hi, I have resolved all the comments/issues reported in this new patch-set. Changes done by Ashutosh Bapat for splitting out create_grouping_paths() into separate functions so that partitionwise aggregate code will use them were based on my partitionwise aggregate changes. Those were like refacto

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-12 Thread Ashutosh Bapat
On Mon, Mar 12, 2018 at 7:49 PM, Jeevan Chalke wrote: > > > On Mon, Mar 12, 2018 at 6:07 PM, Ashutosh Bapat > wrote: >> >> On Fri, Mar 9, 2018 at 4:21 PM, Ashutosh Bapat >> >> GroupPathExtraData now completely absorbs members from and replaces >> OtherUpperPathExtraData. This means that we have t

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-12 Thread Jeevan Chalke
On Mon, Mar 12, 2018 at 6:07 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Fri, Mar 9, 2018 at 4:21 PM, Ashutosh Bapat > > GroupPathExtraData now completely absorbs members from and replaces > OtherUpperPathExtraData. This means that we have to consider a way to > pass GroupPat

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-12 Thread Jeevan Chalke
On Mon, Mar 12, 2018 at 6:07 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Fri, Mar 9, 2018 at 4:21 PM, Ashutosh Bapat > wrote: > > On Thu, Mar 8, 2018 at 7:31 PM, Robert Haas > wrote: > >> > >> This kind of goes along with the suggestion I made yesterday to > >> introduce a

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-12 Thread Ashutosh Bapat
On Fri, Mar 9, 2018 at 4:21 PM, Ashutosh Bapat wrote: > On Thu, Mar 8, 2018 at 7:31 PM, Robert Haas wrote: >> >> This kind of goes along with the suggestion I made yesterday to >> introduce a new function, which at the time I proposed calling >> initialize_grouping_rel(), to set up new grouped or

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-09 Thread Ashutosh Bapat
On Thu, Mar 8, 2018 at 7:31 PM, Robert Haas wrote: > > This kind of goes along with the suggestion I made yesterday to > introduce a new function, which at the time I proposed calling > initialize_grouping_rel(), to set up new grouped or partially grouped > relations. By doing that it would be ea

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-08 Thread Ashutosh Bapat
On Thu, Mar 8, 2018 at 8:02 PM, Jeevan Chalke wrote: > > > On Thu, Mar 8, 2018 at 7:49 PM, Robert Haas wrote: >> >> On Thu, Mar 8, 2018 at 9:15 AM, Jeevan Chalke >> wrote: >> > I am not sure why we don't set reltarget into the grouped_rel too. >> > >> > But if we do so like we did in partially_g

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-08 Thread Jeevan Chalke
On Thu, Mar 8, 2018 at 7:49 PM, Robert Haas wrote: > On Thu, Mar 8, 2018 at 9:15 AM, Jeevan Chalke > wrote: > > I am not sure why we don't set reltarget into the grouped_rel too. > > > > But if we do so like we did in partially_grouped_rel, then it will be lot > > easier for partitionwise aggreg

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-08 Thread Robert Haas
On Thu, Mar 8, 2018 at 9:15 AM, Jeevan Chalke wrote: > I am not sure why we don't set reltarget into the grouped_rel too. > > But if we do so like we did in partially_grouped_rel, then it will be lot > easier for partitionwise aggregate as then we don't have to pass target to > functions creating

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-08 Thread Jeevan Chalke
On Thu, Mar 8, 2018 at 1:15 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > On Wed, Mar 7, 2018 at 8:07 PM, Jeevan Chalke > wrote: > Here are some more review comments esp. on > try_partitionwise_grouping() function. BTW name of that function > doesn't go in sync with enable_partit

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-08 Thread Robert Haas
On Thu, Mar 8, 2018 at 2:45 AM, Ashutosh Bapat wrote: > +grouped_rel->part_scheme = input_rel->part_scheme; > +grouped_rel->nparts = nparts; > +grouped_rel->boundinfo = input_rel->boundinfo; > +grouped_rel->part_rels = part_rels; > > You need to set the part_exprs w

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-07 Thread Ashutosh Bapat
On Wed, Mar 7, 2018 at 8:07 PM, Jeevan Chalke wrote: Here are some more review comments esp. on try_partitionwise_grouping() function. BTW name of that function doesn't go in sync with enable_partitionwise_aggregation (which btw is in sync with enable_fooagg GUCs). But it goes in sync with create_

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-07 Thread Jeevan Chalke
On Wed, Mar 7, 2018 at 1:45 AM, Robert Haas wrote: > On Tue, Mar 6, 2018 at 5:31 AM, Jeevan Chalke > wrote: > > This is in-lined with enable_hashagg GUC. Do you think > > enable_partitionwise_aggregate seems better? But it will be not > consistent > > with other GUC names like enable_hashagg the

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-07 Thread Jeevan Chalke
On Tue, Mar 6, 2018 at 4:59 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > Hi Jeevan, > I am back reviewing this. Here are some comments. > > @@ -1415,7 +1413,8 @@ add_paths_to_append_rel(PlannerInfo *root, > RelOptInfo *rel, > * the unparameterized Append path we are con

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-07 Thread Ashutosh Bapat
On Wed, Mar 7, 2018 at 10:04 AM, Ashutosh Bapat wrote: > On Tue, Mar 6, 2018 at 7:52 PM, Jeevan Chalke > wrote: > >> >> >> Changes look good to me and refactoring will be useful for partitionwise >> patches. >> >> However, will it be good if we add agg_costs into the GroupPathExtraData >> too? >>

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-06 Thread Ashutosh Bapat
On Tue, Mar 6, 2018 at 7:52 PM, Jeevan Chalke wrote: > > > Changes look good to me and refactoring will be useful for partitionwise > patches. > > However, will it be good if we add agg_costs into the GroupPathExtraData > too? > Also can we pass this to the add_partial_paths_to_grouping_rel() and

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-06 Thread Robert Haas
On Tue, Mar 6, 2018 at 5:31 AM, Jeevan Chalke wrote: > This is in-lined with enable_hashagg GUC. Do you think > enable_partitionwise_aggregate seems better? But it will be not consistent > with other GUC names like enable_hashagg then. Well, if I had my way, enable_hashagg would be spelled enable

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-06 Thread Jeevan Chalke
On Tue, Mar 6, 2018 at 4:59 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > Hi Jeevan, > I am back reviewing this. Here are some comments. > > @@ -1415,7 +1413,8 @@ add_paths_to_append_rel(PlannerInfo *root, > RelOptInfo *rel, > * the unparameterized Append path we are con

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-06 Thread Ashutosh Bapat
Hi Jeevan, I am back reviewing this. Here are some comments. @@ -1415,7 +1413,8 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, * the unparameterized Append path we are constructing for the parent. * If not, there's no workable unparameterized path. */

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-06 Thread Jeevan Chalke
On Tue, Mar 6, 2018 at 2:29 AM, Robert Haas wrote: > On Mon, Mar 5, 2018 at 3:56 AM, Jeevan Chalke > wrote: > > However, to perform Gather or Gather Merge once we have all partial paths > > ready, and to avoid too many existing code rearrangement, I am calling > > try_partitionwise_grouping() be

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-05 Thread Robert Haas
On Mon, Mar 5, 2018 at 3:56 AM, Jeevan Chalke wrote: > However, to perform Gather or Gather Merge once we have all partial paths > ready, and to avoid too many existing code rearrangement, I am calling > try_partitionwise_grouping() before we do any aggregation/grouping on whole > relation. By doi

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-05 Thread Jeevan Chalke
On Sat, Mar 3, 2018 at 12:12 AM, Robert Haas wrote: > On Thu, Mar 1, 2018 at 4:52 PM, Robert Haas wrote: > > This is not a full review, but I'm out of time for right now. > > Another thing I see here now is that create_grouping_paths() and > create_child_grouping_paths() are extremely similar.

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-05 Thread Jeevan Chalke
On Fri, Mar 2, 2018 at 3:22 AM, Robert Haas wrote: > On Thu, Mar 1, 2018 at 5:34 AM, Jeevan Chalke > wrote: > > Attached new patchset after rebasing my changes over these changes and on > > latest HEAD. > > +* We have already created a Gather or Gather Merge path atop > cheapest > +

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-02 Thread Robert Haas
On Thu, Mar 1, 2018 at 4:52 PM, Robert Haas wrote: > This is not a full review, but I'm out of time for right now. Another thing I see here now is that create_grouping_paths() and create_child_grouping_paths() are extremely similar. Isn't there some way we can refactor things so that we can reus

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-01 Thread Robert Haas
On Thu, Mar 1, 2018 at 5:34 AM, Jeevan Chalke wrote: > Attached new patchset after rebasing my changes over these changes and on > latest HEAD. +* We have already created a Gather or Gather Merge path atop cheapest +* partial path. Thus the partial path referenced by the Gather no

Re: [HACKERS] Partition-wise aggregation/grouping

2018-03-01 Thread Jeevan Chalke
On Mon, Feb 26, 2018 at 8:03 PM, Robert Haas wrote: > > Committed after incorporating your other fixes and updating the > optimizer README. > Attached new patchset after rebasing my changes over these changes and on latest HEAD. > > -- > Robert Haas > EnterpriseDB: http://www.enterprisedb.com

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-27 Thread Robert Haas
On Tue, Feb 27, 2018 at 4:29 AM, Jeevan Chalke wrote: > Hi Robert, > I had a look over his provided testcase and observed that when we create a > Gather Merge path over a cheapest partial path by sorting it explicitly as > generate_gather_paths won't consider it, we accidentally used cheapest > pa

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-27 Thread Jeevan Chalke
Hi Robert, On Mon, Feb 26, 2018 at 8:03 PM, Robert Haas wrote: > > Committed after incorporating your other fixes and updating the > optimizer README. > Thanks Robert. Off-list Rajkumar has reported an issue. When we have enable_hashagg set to false, and Gather Merge path is chosen, it ended-

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-26 Thread Robert Haas
On Mon, Feb 26, 2018 at 6:38 AM, Jeevan Chalke wrote: > One idea I thought about is to memcpy the struct once we have set all > required fields for grouped_rel so that we don't have to do similar stuff > for partially_grouped_rel. I think that would be a poor idea. We want to copy a few specific

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-26 Thread Jeevan Chalke
Hi Robert, On Fri, Feb 23, 2018 at 2:53 AM, Robert Haas wrote: > On Thu, Feb 8, 2018 at 8:05 AM, Jeevan Chalke > wrote: > > In this attached version, I have rebased my changes over new design of > > partially_grouped_rel. The preparatory changes of adding > > partially_grouped_rel are in 0001.

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-22 Thread Robert Haas
On Thu, Feb 8, 2018 at 8:05 AM, Jeevan Chalke wrote: > In this attached version, I have rebased my changes over new design of > partially_grouped_rel. The preparatory changes of adding > partially_grouped_rel are in 0001. I spent today hacking in 0001; results attached. The big change from your

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-21 Thread Robert Haas
On Thu, Feb 8, 2018 at 8:05 AM, Jeevan Chalke wrote: > 0003 - 0006 are refactoring patches as before. I have committed 0006 with some modifications. In particular, [1] I revised the comments and formatting; [2] I made cost_merge_append() add cpu_tuple_cost * APPEND_CPU_COST_MULTIPLIER in lieu of

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-18 Thread Ashutosh Bapat
Commit 2fb1abaeb016aeb45b9e6d0b81b7a7e92bb251b9, changed enable_partition_wise_join to enable_partitionwise_join. This patch too should use enable_partitionwise_agg instead of enable_partition_wise_agg.

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-14 Thread Jeevan Chalke
On Wed, Feb 14, 2018 at 12:17 PM, Rafia Sabih wrote: > On Tue, Feb 13, 2018 at 6:21 PM, Jeevan Chalke < > jeevan.cha...@enterprisedb.com> wrote: > >> >> I see that partition-wise aggregate plan too uses parallel index, am I >> missing something? >> >> > You're right, I missed that, oops. > >> >>>

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-13 Thread Rafia Sabih
On Tue, Feb 13, 2018 at 6:21 PM, Jeevan Chalke < jeevan.cha...@enterprisedb.com> wrote: > > I see that partition-wise aggregate plan too uses parallel index, am I > missing something? > > You're right, I missed that, oops. > >> Q18 takes some 390 secs with patch and some 147 secs without it. >> >

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-13 Thread Jeevan Chalke
On Tue, Feb 13, 2018 at 12:37 PM, Rafia Sabih wrote: > > I was testing this patch for TPC-H benchmarking and came across following > results, > Thanks Rafia for testing this with TPC-H benchmarking. > > Q1 completes in 229 secs with patch and in 66 secs without it. It looks > like with this pa

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-08 Thread Jeevan Chalke
Hi, In this attached version, I have rebased my changes over new design of partially_grouped_rel. The preparatory changes of adding partially_grouped_rel are in 0001. Also to minimize finalization code duplication, I have refactored them into two separate functions, finalize_sorted_partial_agg_pa

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-02 Thread Robert Haas
On Fri, Feb 2, 2018 at 8:25 AM, Jeevan Chalke wrote: >> The problem is that create_partition_agg_paths() is doing *exactly* >> same thing that add_paths_to_grouping_rel() is already doing inside >> the blocks that say if (grouped_rel->partial_pathlist). We don't need >> two copies of that code.

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-02 Thread Jeevan Chalke
On Fri, Feb 2, 2018 at 1:41 AM, Robert Haas wrote: > On Thu, Feb 1, 2018 at 8:59 AM, Jeevan Chalke > wrote: > > I wrote a patch for this (on current HEAD) and attached separately here. > > Please have a look. > > Yes, this is approximately what I had in mind, though it needs more > work (e.g. it

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-01 Thread Robert Haas
On Thu, Feb 1, 2018 at 8:59 AM, Jeevan Chalke wrote: > I wrote a patch for this (on current HEAD) and attached separately here. > Please have a look. Yes, this is approximately what I had in mind, though it needs more work (e.g. it doesn't removing the clearing of the grouped_rel's partial_pathli

Re: [HACKERS] Partition-wise aggregation/grouping

2018-02-01 Thread Jeevan Chalke
On Thu, Feb 1, 2018 at 1:11 AM, Robert Haas wrote: > On Mon, Jan 29, 2018 at 3:42 AM, Jeevan Chalke > wrote: > > Attached new patch set and rebased it on latest HEAD. > > I strongly dislike add_single_path_to_append_rel. It adds branches > and complexity to code that is already very complex. M

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-31 Thread Robert Haas
On Mon, Jan 29, 2018 at 3:42 AM, Jeevan Chalke wrote: > Attached new patch set and rebased it on latest HEAD. I strongly dislike add_single_path_to_append_rel. It adds branches and complexity to code that is already very complex. Most importantly, why are we adding paths to fields in OtherUpper

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-29 Thread Jeevan Chalke
On Sat, Jan 27, 2018 at 1:35 AM, Robert Haas wrote: > On Thu, Jan 18, 2018 at 8:55 AM, Jeevan Chalke > wrote: > > Attached patch with other review points fixed. > > Committed 0001 and 0002 together, with some cosmetic changes, > including fixing pgindent damage. Thanks Robert. > Please pg

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-26 Thread Robert Haas
On Thu, Jan 18, 2018 at 8:55 AM, Jeevan Chalke wrote: > Attached patch with other review points fixed. Committed 0001 and 0002 together, with some cosmetic changes, including fixing pgindent damage. Please pgindent your patches before submitting. -- Robert Haas EnterpriseDB: http://www.enterpr

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-18 Thread Jeevan Chalke
On Wed, Jan 17, 2018 at 1:18 AM, Robert Haas wrote: > On Tue, Jan 16, 2018 at 3:56 AM, Jeevan Chalke > wrote: > > I will make your suggested changes that is merge create_sort_agg_path() > and > > create_hash_agg_path(). Will name that function as > > create_sort_and_hash_agg_paths(). > > I sugge

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-16 Thread Robert Haas
On Tue, Jan 16, 2018 at 3:56 AM, Jeevan Chalke wrote: > I will make your suggested changes that is merge create_sort_agg_path() and > create_hash_agg_path(). Will name that function as > create_sort_and_hash_agg_paths(). I suggest add_paths_to_grouping_rel() and add_partial_paths_to_grouping_rel(

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-16 Thread Jeevan Chalke
On Tue, Jan 16, 2018 at 3:41 AM, Robert Haas wrote: > On Thu, Jan 11, 2018 at 6:00 AM, Jeevan Chalke > wrote: > > Attached new set of patches adding this. Only patch 0007 (main patch) > and > > 0008 (testcase patch) has changed. > > > > Please have a look and let me know if I missed any. > > I

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-15 Thread Robert Haas
On Thu, Jan 11, 2018 at 6:00 AM, Jeevan Chalke wrote: > Attached new set of patches adding this. Only patch 0007 (main patch) and > 0008 (testcase patch) has changed. > > Please have a look and let me know if I missed any. I spent a little time studying 0001 and 0002 today, as well as their rela

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-11 Thread Jeevan Chalke
> On Thu, Dec 14, 2017 at 4:01 PM, Ashutosh Bapat < > ashutosh.ba...@enterprisedb.com> wrote: > >> >> + >> +-- Partial aggregation as GROUP BY clause does not match with PARTITION >> KEY >> +EXPLAIN (COSTS OFF) >> +SELECT b, sum(a), count(*) FROM pagg_tab GROUP BY b ORDER BY 1, 2, 3; >> +

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-02 Thread Jeevan Chalke
On Thu, Dec 14, 2017 at 4:01 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > > Sure no problem. Take your time. Here's set of comments for 0008. That > ends the first read of all the patches (2nd reading for the core > changes) > > +-- Also, disable parallel paths. > +SET max_parall

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-01 Thread Jeevan Chalke
On Tue, Dec 12, 2017 at 3:43 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > Here are review comments for 0009 > Only full aggregation is pushed on the remote server. > > I think we can live with that for a while but we need to be able to push > down > partial aggregates to the fore

Re: [HACKERS] Partition-wise aggregation/grouping

2018-01-01 Thread Jeevan Chalke
Attached patchset with all the review comments reported so far. On Fri, Dec 1, 2017 at 6:11 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > Continuing with review of 0007. > > + > +/* Copy input rels's relids to grouped rel */ > +grouped_rel->relids = input_rel->relids; > >

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-14 Thread Ashutosh Bapat
On Thu, Dec 14, 2017 at 4:01 PM, Ashutosh Bapat wrote: > + > +-- Test when input relation for grouping is dummy > +EXPLAIN (COSTS OFF) > +SELECT c, sum(a) FROM pagg_tab WHERE 1 = 2 GROUP BY c; > + QUERY PLAN > + > + HashAggregate > + Group Key: pagg_tab.

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-14 Thread Ashutosh Bapat
On Thu, Dec 14, 2017 at 4:01 PM, Ashutosh Bapat wrote: > > + > +EXPLAIN (COSTS OFF) > +SELECT a FROM pagg_tab GROUP BY a ORDER BY 1; > + QUERY PLAN > +- > + Group > + Group Key: pagg_tab_p1.a > + -> Merge Append > + Sor

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-14 Thread Ashutosh Bapat
On Wed, Dec 13, 2017 at 6:37 PM, Jeevan Chalke wrote: > > > On Tue, Dec 12, 2017 at 3:43 PM, Ashutosh Bapat > wrote: >> >> Here are review comments for 0009 > > > Thank you, Ashutosh for the detailed review so far. > > I am working on your reviews but since parallel Append is now committed, > I n

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-13 Thread Jeevan Chalke
On Tue, Dec 12, 2017 at 3:43 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > Here are review comments for 0009 > Thank you, Ashutosh for the detailed review so far. I am working on your reviews but since parallel Append is now committed, I need to re-base my changes over it and ne

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-12 Thread Ashutosh Bapat
Here are review comments for 0009 Only full aggregation is pushed on the remote server. I think we can live with that for a while but we need to be able to push down partial aggregates to the foreign server. I agree that it needs some infrastructure to serialized and deserialize the partial aggreg

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-03 Thread Ashutosh Bapat
On Sat, Dec 2, 2017 at 4:08 AM, Robert Haas wrote: > On Fri, Dec 1, 2017 at 7:41 AM, Ashutosh Bapat > wrote: >> This code creates plans where there are multiple Gather nodes under an Append >> node. > > We should avoid that. Starting and stopping workers is inefficient, > and precludes things li

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-01 Thread Robert Haas
On Fri, Dec 1, 2017 at 7:41 AM, Ashutosh Bapat wrote: > This code creates plans where there are multiple Gather nodes under an Append > node. We should avoid that. Starting and stopping workers is inefficient, and precludes things like turning the Append into a Parallel Append. > AFAIU, the wor

Re: [HACKERS] Partition-wise aggregation/grouping

2017-12-01 Thread Ashutosh Bapat
Continuing with review of 0007. + +/* Copy input rels's relids to grouped rel */ +grouped_rel->relids = input_rel->relids; Isn't this done in fetch_upper_rel()? Why do we need it here? There's also a similar hunk in create_grouping_paths() which doesn't look appropriate. I guess, you need

Re: [HACKERS] Partition-wise aggregation/grouping

2017-11-29 Thread Michael Paquier
On Tue, Nov 28, 2017 at 5:50 PM, Jeevan Chalke wrote: > [snip] This is still a hot topic so I am moving it to next CF. -- Michael

Re: [HACKERS] Partition-wise aggregation/grouping

2017-11-28 Thread Jeevan Chalke
On Tue, Nov 28, 2017 at 12:37 PM, Rajkumar Raghuwanshi < rajkumar.raghuwan...@enterprisedb.com> wrote: > On Thu, Nov 23, 2017 at 6:38 PM, Jeevan Chalke > wrote: > > Let me know if I missed any comment to be fixed. > > Hi, > > I have applied v8 patches on commit id 8735978e7aebfbc499843630131c18 >

  1   2   >