Re: [HACKERS] SELECT DISTINCT i FROM dtest ORDER BY j - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] SELECT DISTINCT i FROM dtest ORDER BY j
Date
Msg-id 199812201903.OAA01434@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] SELECT DISTINCT i FROM dtest ORDER BY j  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> The trouble is that if you have several tuples with the same i and
> different j, doing the DISTINCT first implies throwing away all but
> one of those tuples.  Which one do you keep?  It matters because
> some of those tuples might sort differently than others.
> 
> As far as I can see, this combination of features is not well-defined on
> its surface.  You have to make some additional assumptions (about which
> of the possible j values is kept for sorting) in order to define a
> unique result.

That is an interesting argument.  It suggests it should not be a TODO
item.  I can see cases where you would want to do the DISTINCT before
the ORDER BY, so the current behavior seems correct.

Removing it from TODO list.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] SELECT DISTINCT i FROM dtest ORDER BY j
Next
From: Oleg Broytmann
Date:
Subject: PostgreSQL 6.4 like bug(?)