Re: [GENERAL] Random not so random

2004-10-11 Thread Marco Colombo
On Mon, 4 Oct 2004, Bruno Wolff III wrote: On Mon, Oct 04, 2004 at 18:58:41 +0200, Marco Colombo <[EMAIL PROTECTED]> wrote: Actually, that should be done each time the random() function is evaluated. (I have no familiarity with the code, so please That may be overkill, since I don't think that ran

Re: [GENERAL] Random not so random

2004-10-07 Thread Bruno Wolff III
On Thu, Oct 07, 2004 at 12:08:51 +0200, Marco Colombo <[EMAIL PROTECTED]> wrote: > On Wed, 6 Oct 2004, Bruno Wolff III wrote: > > >You don't necessarily need to break SHA1 to be able to track the internal > >state. > > Well, I'm not an expert. I base my knowledge on what other people say. > Quo

Re: [GENERAL] Random not so random

2004-10-07 Thread Marco Colombo
On Wed, 6 Oct 2004, Bruno Wolff III wrote: I am going to keep this on general for now, since it seems like other people might be interested even though it is straying a somewhat off topic. Agreed. Anyone who's not really interested on /dev/[u]random issues should jump right to the last paragraphs o

Re: [GENERAL] Random not so random

2004-10-06 Thread Marco Colombo
On Tue, 5 Oct 2004, Tom Lane wrote: now.tv_sec, and it's perfectly portable. No one in their right mind expects random(3) to be cryptographically secure anyway, so doing more doesn't seem warranted. Tom, having a source of "real" random data isn't useful just for crypto applications. No PRNG is pe

Re: [GENERAL] Random not so random

2004-10-06 Thread Bruno Wolff III
I am going to keep this on general for now, since it seems like other people might be interested even though it is straying a somewhat off topic. On Wed, Oct 06, 2004 at 18:02:39 +0200, Marco Colombo <[EMAIL PROTECTED]> wrote: > > It depends. What's wrong with a SQL function taking long to > co

Re: [GENERAL] Random not so random

2004-10-06 Thread Michael Fuhr
On Tue, Oct 05, 2004 at 07:23:32AM -0600, Michael Fuhr wrote: > On Tue, Oct 05, 2004 at 02:39:13PM +0200, Harald Fuchs wrote: > > > I think we don't need the randomness provided by /dev/[u]random. How > > about XORing in getpid? > > What about making the seeding mechanism and perhaps random()'s

Re: [GENERAL] Random not so random

2004-10-06 Thread Bruno Wolff III
On Tue, Oct 05, 2004 at 11:27:05 +0200, Marco Colombo <[EMAIL PROTECTED]> wrote: > On Mon, 4 Oct 2004, Bruno Wolff III wrote: > > >You don't want to use /dev/random. You aren't going to get better random > >numbers that way and blocking reads is a big problem. > > Sure you are. As far as the en

Re: [GENERAL] Random not so random

2004-10-06 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Dann Corbit" <[EMAIL PROTECTED]> writes: > A better way would be to seed a Mersenne Twister PRNG at server startup > time and then use the same generator for all subsequent calls. > http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html > The period is exception

Re: [GENERAL] Random not so random

2004-10-05 Thread D. Stimits
Vivek Khera wrote: "DS" == D Stimits <[EMAIL PROTECTED]> writes: DS> If it uses the same seed from the connection, then all randoms within DS> a connect that has not reconnected will use the same seed. Which means DS> the same sequence will be generated each time, which is why it is DS> pseudo-ran

Re: [GENERAL] Random not so random

2004-10-05 Thread Vivek Khera
> "DS" == D Stimits <[EMAIL PROTECTED]> writes: DS> If it uses the same seed from the connection, then all randoms within DS> a connect that has not reconnected will use the same seed. Which means DS> the same sequence will be generated each time, which is why it is DS> pseudo-random and not r

Re: [GENERAL] Random not so random

2004-10-05 Thread Dann Corbit
5, 2004 9:34 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [GENERAL] Random not so random > > > A better way would be to seed a Mersenne Twister PRNG at > server startup time and then use the same generator for all > subsequent calls. > http://w

Re: [GENERAL] Random not so random

2004-10-05 Thread Dann Corbit
age- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of D. Stimits > Sent: Monday, October 04, 2004 7:23 AM > Cc: [EMAIL PROTECTED] > Subject: Re: [GENERAL] Random not so random > > > Tom Lane wrote: > > "Arnau Rebassa" <[EMAIL PROTECTED]>

Re: [GENERAL] Random not so random

2004-10-05 Thread Tom Lane
Harald Fuchs <[EMAIL PROTECTED]> writes: >> Tom Lane <[EMAIL PROTECTED]> wrote: It might improve matters to make the code do something like srandom((unsigned int) (now.tv_sec ^ now.tv_usec)); > I think we don't need the randomness provided by /dev/[u]random. How > about XORing in getpid

Re: [GENERAL] Random not so random

2004-10-05 Thread Michael Fuhr
On Tue, Oct 05, 2004 at 02:39:13PM +0200, Harald Fuchs wrote: > I think we don't need the randomness provided by /dev/[u]random. How > about XORing in getpid? What about making the seeding mechanism and perhaps random()'s behavior configurable? -- Michael Fuhr http://www.fuhr.org/~mfuhr/

Re: [GENERAL] Random not so random

2004-10-05 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, Bruno Wolff III <[EMAIL PROTECTED]> writes: > On Mon, Oct 04, 2004 at 10:14:19 -0400, > Tom Lane <[EMAIL PROTECTED]> wrote: >> >> It occurs to me that you might be seeing predictability as an indirect >> result of something else you are doing that somehow tends t

Re: [GENERAL] Random not so random

2004-10-04 Thread Tom Lane
"D. Stimits" <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Hmm. postmaster.c does this during startup of each backend process: >> >> gettimeofday(&now, &tz); >> srandom((unsigned int) now.tv_usec); > If it uses the same seed from the connection, then all randoms within a > connect that has n

Re: [GENERAL] Random not so random

2004-10-04 Thread D. Stimits
Tom Lane wrote: "Arnau Rebassa" <[EMAIL PROTECTED]> writes: I'm using a debian linux as OS with a 2.4 kernel running on it. Incidentally, are you reconnecting every time or is it that multiple calls in a single session are returning the same record? I'm reconnecting each time I want to retriev

Re: [GENERAL] Random not so random

2004-10-04 Thread Bruno Wolff III
On Mon, Oct 04, 2004 at 18:58:41 +0200, Marco Colombo <[EMAIL PROTECTED]> wrote: > > Actually, that should be done each time the random() function > is evaluated. (I have no familiarity with the code, so please That may be overkill, since I don't think that random has been advertised as a secur

Re: [GENERAL] Random not so random

2004-10-04 Thread Marco Colombo
On Mon, 4 Oct 2004, Tom Lane wrote: "Arnau Rebassa" <[EMAIL PROTECTED]> writes: I'm using a debian linux as OS with a 2.4 kernel running on it. Incidentally, are you reconnecting every time or is it that multiple calls in a single session are returning the same record? I'm reconnecting each t

Re: [GENERAL] Random not so random

2004-10-04 Thread Bruno Wolff III
On Mon, Oct 04, 2004 at 10:14:19 -0400, Tom Lane <[EMAIL PROTECTED]> wrote: > > It occurs to me that you might be seeing predictability as an indirect > result of something else you are doing that somehow tends to synchronize > the backend start times. Are you connecting from a cron script that

Re: [GENERAL] Random not so random

2004-10-04 Thread Tom Lane
"Arnau Rebassa" <[EMAIL PROTECTED]> writes: > I'm using a debian linux as OS with a 2.4 kernel running on it. >> Incidentally, are you reconnecting every time or is it that multiple calls >> in a single session are returning the same record? > I'm reconnecting each time I want to retrieve a

Re: [GENERAL] Random not so random

2004-10-04 Thread Neil Conway
Arnau Rebassa wrote: I don't know if there is the possibility to seed the random number generator manually, anybody knows it? setseed() -Neil ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joi

Re: [GENERAL] Random not so random

2004-10-04 Thread Arnau Rebassa
Hi Greg, What OS is this? Postgres is just using your OS's random()/srandom() calls. On some platforms these may be poorly implemented and not very random. I'm using a debian linux as OS with a 2.4 kernel running on it. Incidentally, are you reconnecting every time or is it that multiple calls i

[GENERAL] Random not so random

2004-10-03 Thread Arnau Rebassa
Hi everybody, I'm doing the following query: select * from messages order by random() limit 1; in the table messages I have more than 200 messages and a lot of times, the message retrieved is the same. Anybody knows how I could do a more "random" random? Thank you very much -- Arnau __

Re: [GENERAL] Random not so random

2004-10-01 Thread Greg Stark
"Arnau Rebassa" <[EMAIL PROTECTED]> writes: >select * from messages order by random() limit 1; > > in the table messages I have more than 200 messages and a lot of times, the > message retrieved is the same. Anybody knows how I could do a more "random" > random? What OS is this? Postgres is

Re: [GENERAL] Random not so random

2004-10-01 Thread Jean-Luc Lachance
Use a SERIAL id on messages, then Select * from messages where id = int8( random() * currval({sequence_name})); Arnau Rebassa wrote: Hi everybody, I'm doing the following query: select * from messages order by random() limit 1; in the table messages I have more than 200 messages and a lot of time

[GENERAL] Random not so random

2004-10-01 Thread Arnau Rebassa
Hi everybody, I'm doing the following query: select * from messages order by random() limit 1; in the table messages I have more than 200 messages and a lot of times, the message retrieved is the same. Anybody knows how I could do a more "random" random? Thank you very much -- Arnau __