PostgreSQL random () function quality?

Let's say I create a table foo with a column row, which should be a very large random integer.

CREATE TABLE foo ( bar bigint DEFAULT round(((9223372036854775807::bigint)::double precision * random())) NOT NULL, baz text ); 

Is this the best way to do this? Can anyone talk about the quality of the PostgreSQL random() function? Is multiplication here a disguise of entropy?

Note that I have good hardware entropy in /dev/random .

+5
random postgresql entropy prng
Mar 22 2018-12-12T00:
source share
1 answer

Postgresql random is based on its own portable implementation of POSIX erand48 . This is a linear congruent PRNG in a 48-bit domain.

If you need a stronger look at the gen_random_bytes pg_crypto function, which is used to create cryptographically strong entropy.

+11
Mar 22 '12 at 5:08
source share



All Articles