OSDN Git Service

Per recent discussion on -hackers, we should sometimes reorder the
authorNeil Conway <neilc@samurai.com>
Sun, 5 Mar 2006 21:34:34 +0000 (21:34 +0000)
committerNeil Conway <neilc@samurai.com>
Sun, 5 Mar 2006 21:34:34 +0000 (21:34 +0000)
commit99114a2473a57384246e2f61c79b97ccd376acc8
treedbd24450f7fb9cecb85f90db65a40b7fb0f68673
parentf9520ac110144762336da839b4f3a4ef0e145356
Per recent discussion on -hackers, we should sometimes reorder the
columns of the grouping clause to avoid redundant sorts. The optimizer
is not currently capable of doing this, so this patch implements a
simple hack in the analysis phase (transformGroupClause): if any
subset of the GROUP BY clause matches a prefix of the ORDER BY list,
that prefix is moved to the front of the GROUP BY clause. This
shouldn't change the semantics of the query, and allows a redundant
sort to be avoided for queries like "GROUP BY a, b ORDER BY b".
src/backend/parser/parse_clause.c