Re: Final Patch for GROUPING SETS - unrecognized node type: 347

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Final Patch for GROUPING SETS - unrecognized node type: 347
Date: 2014-09-07 13:11:49
Message-ID: 87lhpv8u9q.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Tomas" == Tomas Vondra <tv(at)fuzzy(dot)cz> writes:

>> It's not one sort per grouping set, it's the minimal number of
>> sorts needed to express the result as a union of ROLLUP
>> clauses. The planner code will (I believe) always find the
>> smallest number of sorts needed.

Tomas> You're probably right. Although when doing GROUP BY CUBE
Tomas> (a,b,c,a) I get one more ChainAggregate than with
Tomas> CUBE(a,b,c). and we seem to compute all the aggregates
Tomas> twice. Not sure if we need to address this though, because
Tomas> it's mostly user's fault.

Hm. Yeah, you're right that the number of sorts is not optimal there.
We can look into that.

As for computing it all twice, there's currently no attempt to
optimize multiple identical grouping sets into multiple projections of
a single grouping set result. CUBE(a,b,c,a) has twice as many grouping
sets as CUBE(a,b,c) does, even though all the extra ones are duplicates.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2014-09-07 13:14:01 Re: Allowing implicit 'text' -> xml|json|jsonb
Previous Message Tomas Vondra 2014-09-07 12:33:05 Re: Final Patch for GROUPING SETS - unrecognized node type: 347