Re: [PATCH] Lazy hashaggregate when no aggregation is needed
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ants Aasma <ants@cybertec.at>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>, Francois Deliege <fdeliege@gmail.com>
Date: 2012-03-28T14:15:58Z
Lists: pgsql-hackers
Ants Aasma <ants@cybertec.at> writes: > A user complained on pgsql-performance that SELECT col FROM table > GROUP BY col LIMIT 2; performs a full table scan. ISTM that it's safe > to return tuples from hash-aggregate as they are found when no > aggregate functions are in use. Attached is a first shot at that. As I commented in the other thread, the user would be a lot better off if he'd had an index on the column in question. I'm not sure it's worth complicating the hashagg logic when an indexscan + groupagg would address the case better. regards, tom lane