can_partial_agg use root->processed_groupClause instead of parse->groupClause

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: can_partial_agg use root->processed_groupClause instead of parse->groupClause
Date: 2024-11-06 07:04:00
Message-ID: CACJufxH=r9WiBNfyi7hWADRLf9LqKmP02CaG-+Aff6mOaL9TiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

static bool
can_partial_agg(PlannerInfo *root)
{
Query *parse = root->parse;
if (!parse->hasAggs && root->groupClause == NIL)
{
/*
* We don't know how to do parallel aggregation unless we have either
* some aggregates or a grouping clause.
*/
return false;
}
else if (parse->groupingSets)
{
return false;
}
else if (root->hasNonPartialAggs || root->hasNonSerialAggs)
{
return false;
}
return true;
}

while reviewing other patches,
i am wondering should we change
"if (!parse->hasAggs && parse->groupClause == NIL)"
to
"if (!parse->hasAggs && root->processed_groupClause == NIL)"

root->processed_groupClause same as parse->groupClause
but removed some not necessary groupby logic,
e.g. "group by 1 = 1" cases.
so that in some corner cases, GroupPathExtraData->flags are properly set.

contrived corner case:
select 1 from t0 group by 1= 1;

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-11-06 07:10:23 Re: general purpose array_sort
Previous Message wenhui qiu 2024-11-06 06:32:16 Re: optimize the value of vacthresh and anlthresh