Re: Randomize Result Set Order

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Randomize Result Set Order
Дата
Msg-id 200109281953.f8SJrU714614@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: Randomize Result Set Order  (merlyn@stonehenge.com (Randal L. Schwartz))
Список pgsql-general
> >>>>> "Ryan" == Ryan Mahoney <ryan@paymentalliance.net> writes:
>
> Ryan> Is there an easy way to randomize the order that records get returned in?
> Ryan> Don't imagine there is - but thought I'd ask  ;)
>
> order by random()
>
> I even threw it into my latest Linux Magazine column, expounding the
> virtues of the official Database of RedHat.

I still haven't figured out how that function call does this trick.
My guess is that because we can order by a function, it is calling
random() for every row and just sorting on that.  In normal usage, the
functionm would reference database columns.

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

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

Предыдущее
От: "Steve Wolfe"
Дата:
Сообщение: Re: Performance question (stripped down the problem)
Следующее
От: "Daniel M . Kurry"
Дата:
Сообщение: Re: UNIQUE constraint and indexing