Re: Selecting a random row

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "gnari" <gnari(at)simnet(dot)is>
Cc: pgsql-general(at)postgresql(dot)org, "Kari Lavikka" <tuner(at)bdb(dot)fi>
Subject: Re: Selecting a random row
Date: 2004-11-04 17:40:41
Message-ID: 26807.1099590041@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"gnari" <gnari(at)simnet(dot)is> writes:
> Tthe problem with this is that this is not very random.
> If the uids 30000 to 39999 have been missing, but
> the uids are more or less contiguous apart from that,
> the uid 40000 would be 10000 times more likely to be selected
> than average.

There is some discussion of selecting random rows in the list archives.
My recollection is that we decided the only way to be fast *and*
truly random was to dedicate an extra column to be a random key.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kari Lavikka 2004-11-04 17:56:35 Re: Selecting a random row
Previous Message Pierre-Frédéric Caillaud 2004-11-04 17:25:16 Re: Restricting Postgres