Vitaly Belman <vitalib@012.net.il> writes:
> The problem is that addind them all to GROUP BY causes a performance
> loss.
Really? I'd think that there'd be no visible loss if the earlier
fields of the GROUP BY are already unique. The sort comparison
should stop at the first field that determines the sort order.
Can you provide a self-contained example?
regards, tom lane