Re: Selecting K random rows - efficiently!

From: cluster <skrald(at)amossen(dot)dk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Selecting K random rows - efficiently!
Date: 2007-10-24 08:59:46
Message-ID: ffn1i3$2f16$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Another way to look at the problem is: How do I sample a subset of size
K efficiently? A query like

SAMPLE 1000 OF
(SELECT * FROM mydata WHERE <some condition>)

should return 1000 random rows from the select statement so that two
consecutive evaluations of the query would only with very little
probability return the same 1000 rows.
(Yes, I know that "SAMPLE 1000 OF" is not valid SQL)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Stark 2007-10-24 09:13:35 Re: deadlock detected, only selects (not select-for-update)
Previous Message Laurent ROCHE 2007-10-24 08:42:39 Re : pg_dump auto login