Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-20 Thread Jim C. Nasby
On Tue, Sep 20, 2005 at 06:45:07PM -0400, Bruce Momjian wrote: > Jim C. Nasby wrote: > > > What do these URL's have that the current TODO does not? > > > > > > * Consider using hash buckets to do DISTINCT, rather than sorting > > > > > > This would be beneficial when there are few distinct valu

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-20 Thread Bruce Momjian
Jim C. Nasby wrote: > > What do these URL's have that the current TODO does not? > > > > * Consider using hash buckets to do DISTINCT, rather than sorting > > > > This would be beneficial when there are few distinct values. This is > > already used by GROUP BY. > > Maybe it's just me, but t

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-20 Thread Jim C. Nasby
On Tue, Sep 20, 2005 at 05:05:05PM -0400, Bruce Momjian wrote: > Jim C. Nasby wrote: > > On Mon, Sep 19, 2005 at 10:16:36PM -0400, Bruce Momjian wrote: > > > > > > Added to TODO: > > > > > > * Allow DISTINCT to use hashing like GROUP BY > > > > 3 lines above we have... > > Consider using hash

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-20 Thread Bruce Momjian
Jim C. Nasby wrote: > On Mon, Sep 19, 2005 at 10:16:36PM -0400, Bruce Momjian wrote: > > > > Added to TODO: > > > > * Allow DISTINCT to use hashing like GROUP BY > > 3 lines above we have... > Consider using hash buckets to do DISTINCT, rather than sorting > This would be beneficial when th

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-20 Thread Jim C. Nasby
On Mon, Sep 19, 2005 at 10:16:36PM -0400, Bruce Momjian wrote: > > Added to TODO: > > * Allow DISTINCT to use hashing like GROUP BY 3 lines above we have... Consider using hash buckets to do DISTINCT, rather than sorting This would be beneficial when there are few distinct values. Can y

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-19 Thread Bruce Momjian
Added to TODO: * Allow DISTINCT to use hashing like GROUP BY --- Greg Stark wrote: > > Neil Conway <[EMAIL PROTECTED]> writes: > > > On Mon, 2005-19-09 at 16:27 +0200, Hans-J?rgen Sch?nig wrote: > > > I was wond

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-19 Thread Greg Stark
Tom Lane <[EMAIL PROTECTED]> 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

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-19 Thread Tom Lane
Greg Stark <[EMAIL PROTECTED]> writes: > DISTINCT is really just special a case of GROUP BY. Even DISTINCT ON is just > GROUP BY with a kind of "first()" aggregate function. What would be really > neat would be to teach GROUP BY about first() and last() and how it can skip > over some index entries

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-19 Thread Greg Stark
Neil Conway <[EMAIL PROTECTED]> writes: > On Mon, 2005-19-09 at 16:27 +0200, Hans-Jürgen Schönig wrote: > > I was wondering whether it is possible to teach the planner to handle > > DISTINCT in a more efficient way: > [...] > > Isn't it possible to perform the same operation using a > > HashAggr

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-19 Thread Tom Lane
=?ISO-8859-1?Q?Hans-J=FCrgen_Sch=F6nig?= <[EMAIL PROTECTED]> writes: > I was wondering whether it is possible to teach the planner to handle > DISTINCT in a more efficient way: Probably (although the interactions with ORDER BY might be tricky). No one has touched that part of the planner in a ver

Re: [HACKERS] DISTINCT vs. GROUP BY

2005-09-19 Thread Neil Conway
On Mon, 2005-19-09 at 16:27 +0200, Hans-Jürgen Schönig wrote: > I was wondering whether it is possible to teach the planner to handle > DISTINCT in a more efficient way: [...] > Isn't it possible to perform the same operation using a > HashAggregate? One problem is that DISTINCT ON is defined to