Re: replace oidrand() with random_sample()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: replace oidrand() with random_sample()
Дата
Msg-id 10373.1042680110@sss.pgh.pa.us
обсуждение исходный текст
Ответ на replace oidrand() with random_sample()  (Neil Conway <neilc@samurai.com>)
Ответы Re: replace oidrand() with random_sample()  (Neil Conway <neilc@samurai.com>)
Список pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> The "random" regression test uses a function called oidrand(), which
> takes two parameters, an OID x and an integer y, and returns "true" with
> probability 1/y (the OID argument is ignored). This can be useful -- for
> example, it can be used to select a random sampling of the rows in a
> table (which is what the "random" regression test uses it for).

Do we actually need a separate function at all?  Seems like
    random() < 1.0/y
would accomplish the same result.

I agree that oidrand() is crufty and no longer useful, but I had
hesitated to rip it out, for fear that somebody somewhere might still
be using it.  It's not like it's costing us any maintenance effort
to leave it there.

            regards, tom lane

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

Предыдущее
От: Neil Conway
Дата:
Сообщение: replace oidrand() with random_sample()
Следующее
От: "Christopher Kings-Lynne"
Дата:
Сообщение: Re: fix broken regression tests