Re: DISTINCT vs. GROUP BY - Mailing list pgsql-hackers

From Greg Stark
Subject Re: DISTINCT vs. GROUP BY
Date
Msg-id 87fys0ojrg.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: DISTINCT vs. GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> I do think hash aggregation is a plausible alternative implementation of
> plain DISTINCT, but I don't see the case for using it for DISTINCT ON.

It could be done without presorting the input though not with a simple
first()-like function. It would have be a sort of two-argument min() function
that kept a state variable for the smallest value found so far of the sort
key.

My main motivation here is that it's odd to have two code paths for
implementing the two language constructs when one is really just a special
case of the other. It's a source of cases like this where the code to
implement a query path exists but isn't accessible due to the way the query is
written.

-- 
greg



pgsql-hackers by date:

Previous
From: Patrick Welche
Date:
Subject: Re: postmaster core dump
Next
From: Bruce Momjian
Date:
Subject: Re: Spinlocks, yet again: analysis and proposed patches