From: r.zharkov@postgrespro.ru
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Strange behavior of the random() function
Date: Wed, 26 Sep 2018 09:54:56 +0700
Message-ID: <00b2388c8e5a8d1dfb693d2b59b00722@postgrespro.ru> (raw)
Hello,
Can anybody explain me that strange behavior?
select random() as "rnd", random() as "rnd1", random() as "rnd2"
from generate_series( 1, 5 );
---
0.948556384071708 0.769186236895621 0.381390900816768
0.684488877654076 0.594888080842793 0.214444123208523
0.668408528901637 0.452859566546977 0.924952184315771
All of the values are different.
select random() as "rnd", random() as "rnd1", random() as "rnd2"
from generate_series( 1, 3 )
order by random();
---
0.166236794553697 0.166236794553697 0.166236794553697
0.629051928408444 0.629051928408444 0.629051928408444
0.698161978274584 0.698161978274584 0.698161978274584
All values in any row are the same.
select random() as "rnd", random() as "rnd1", random() as "rnd2"
from generate_series( 1, 3 )
order by random() || 'test';
---
0.569052047561854 0.531697370111942 0.338135569822043
0.880468992516398 0.172520748339593 0.0296505615115166
0.862012444529682 0.119546371512115 0.21626165881753
All of the values are different again.
Is it a bug?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: r.zharkov@postgrespro.ru
Subject: Re: Strange behavior of the random() function
In-Reply-To: <00b2388c8e5a8d1dfb693d2b59b00722@postgrespro.ru>
References: <00b2388c8e5a8d1dfb693d2b59b00722@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox