| From: | Kari Lavikka <tuner(at)bdb(dot)fi> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Selecting a random row |
| Date: | 2004-11-04 17:56:35 |
| Message-ID: | Pine.HPX.4.51.0411041950160.3138@purple.bdb.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
> 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 are some gaps but distribution of them is quite uniform. And results
seem to be random enuff for this particular purpose.
> Maybe using an OFFSET of (count(*) * random()) and a LIMIT 1
> could be practical.
Something like OFFSET (random() * 10) could be used for additional
randomness of course.
|\__/|
( oo ) Kari Lavikka - tuner(at)bdb(dot)fi
__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _
""
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martin Foster | 2004-11-04 17:59:25 | Re: Restricting Postgres |
| Previous Message | Tom Lane | 2004-11-04 17:40:41 | Re: Selecting a random row |