]> git.ipfire.org Git - thirdparty/postgresql.git/commit
When we have successfully optimized a MIN or MAX aggregate into an indexscan,
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 27 Mar 2008 19:06:23 +0000 (19:06 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 27 Mar 2008 19:06:23 +0000 (19:06 +0000)
commit707867e9fd9693f22034f3e71cc6efe3e90f1244
tree28045f99d4f7d981fba67a4c554fb2eabfc0ed16
parent1c0e618e174871676c7fa129034b2a0942b608b7
When we have successfully optimized a MIN or MAX aggregate into an indexscan,
the query result must be exactly one row (since we don't do this when there's
any GROUP BY).  Therefore any ORDER BY or DISTINCT attached to the query is
useless and can be dropped.  Aside from saving useless cycles, this protects
us against problems with matching the hacked-up tlist entries to sort clauses,
as seen in a bug report from Taiki Yamaguchi.  We might need to work harder
if we ever try to optimize grouped queries with this approach, but this
solution will do for now.
src/backend/optimizer/plan/planner.c