From: | Lukas Smith <smith(at)pooteeweet(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: column order in GROUP BY |
Date: | 2006-03-03 08:16:39 |
Message-ID: | 4407FB67.4020201@pooteeweet.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane wrote:
> Neil Conway <neilc(at)samurai(dot)com> writes:
>> A simple hack might help with a subset of this problem, though. For
>> queries with both ORDER BY and GROUP BY clauses, we can sort the
>> grouping columns according to their position in the ORDER BY list. So,
>> given a query like:
>
>> SELECT a, b, max(c) FROM t1 GROUP BY a, b ORDER BY b;
>
>> We can avoid the redundant sort for the ORDER BY by grouping by (b, a)
>> instead. Attached is a proof-of-concept patch that implements this,
>> although it's an enormous kludge.
>
> I think that's the wrong place. transformGroupClause is the right
> place. It already does some hacking to try to make the GROUP BY
> semantics match ORDER BY, but it doesn't think to try reordering
> the GROUP BY items.
Does it also throw out unnecessary columns in the GROUP BY? Like when
the GROUP BY contains multiple columns of which one (or a set) already
uniquely identifies every row.
regards,
Lukas
From | Date | Subject | |
---|---|---|---|
Next Message | Csaba Nagy | 2006-03-03 09:08:05 | Re: Automatic free space map filling |
Previous Message | D'Arcy J.M. Cain | 2006-03-03 06:51:20 | Re: PostgreSQL Anniversary Summit, Call for Contributions |