Re: some random() clarification needed

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: some random() clarification needed
Дата
Msg-id CAKFQuwYtqV0OJLEZbM25GNp0cdt6LmWfcqEEqFjU9mMnjRYpmw@mail.gmail.com
обсуждение исходный текст
Ответ на some random() clarification needed  (Marc Millas <marc.millas@mokadb.com>)
Ответы Re: some random() clarification needed  (Marc Millas <marc.millas@mokadb.com>)
Re: some random() clarification needed  (Marc Millas <marc.millas@mokadb.com>)
Список pgsql-general
On Tue, Jul 14, 2020 at 8:15 AM Marc Millas <marc.millas@mokadb.com> wrote:
select id, prenom from prenoms where id=ceiling(random()*2582);

expecting to get, allways, one line.
But its not the case.
around 15% of time I get 0 lines which is already quite strange to me.
but 10% of time, I get a random number of lines, until now up to 4.
even weirder (to me !)

so, can someone please clarify ?


You are basically asking:

For each row in my table compare the id to some random number and if they match return that row, otherwise skip it.  The random number being compared to is different for each row because random() is volatile and thus evaluated for each row.

David J.

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

Предыдущее
От: Marc Millas
Дата:
Сообщение: some random() clarification needed
Следующее
От: David Gasa i Castell
Дата:
Сообщение: Surprising connection issue