Re: ORDER BY and DISTINCT ON

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ORDER BY and DISTINCT ON
Дата
Msg-id 3345.1071443373@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: ORDER BY and DISTINCT ON  (Greg Stark <gsstark@mit.edu>)
Ответы Re: ORDER BY and DISTINCT ON  (Neil Conway <neilc@samurai.com>)
Re: ORDER BY and DISTINCT ON  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-hackers
Greg Stark <gsstark@mit.edu> writes:
> So, like DISTINCT ON, GROUP BY also insists on the user providing the
> ORDER BY clause. I suppose you could argue postgres could implicitly
> introduce an extra sort step when the user-provided ORDER BY doesn't
> match the GROUP BY or DISTINCT ON clause but it seems like the user is
> probably confused if he really wants a random record and then sort on
> columns that weren't sorted previous to the DISTINCT ON.

This was discussed before --- see the archives.  I believe the
conclusion was that the results would actually be nondeterministic
if we used two sort steps (that's what the code comment means by
"rather unpredictable").  This is not unrelated to the reasons why
people consider DISTINCT ON to be a messy feature ... ideally it
should be orthogonal to ORDER BY, but it simply isn't.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Resurrecting pg_upgrade
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Archives