| From: | Marc Millas <marc(dot)millas(at)mokadb(dot)com> |
|---|---|
| To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
| Cc: | "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: some random() clarification needed |
| Date: | 2020-07-14 15:26:33 |
| Message-ID: | CADX_1aYt+YsTxQmKRB4AH6VahmCcuWYr_o=Go5HBqPPtZLX_ig@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Ok, thanks for the clarification.
Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com
On Tue, Jul 14, 2020 at 5:24 PM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Tue, Jul 14, 2020 at 8:15 AM Marc Millas <marc(dot)millas(at)mokadb(dot)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.
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David G. Johnston | 2020-07-14 15:35:14 | Re: Surprising connection issue |
| Previous Message | David Gasa i Castell | 2020-07-14 15:25:24 | Surprising connection issue |