From: | Steve Heaven <steve(at)thornet(dot)co(dot)uk> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Statistical Analysis |
Date: | 2000-07-25 07:47:57 |
Message-ID: | 3.0.1.32.20000725084757.00b7bb30@mail.thornet.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
At 20:18 24/07/00 -0400, you wrote:
>Sigh, forgot to mention the solution. There's an undocumented function:
>
> * bool oidrand (oid o, int4 X)-
> * takes in an oid and a int4 X, and will return 'true'
> * about 1/X of the time.
>
>typically used like this:
>
>-- select roughly 1/10 of the tuples
>SELECT * FROM onek WHERE oidrand(onek.oid, 10);
>
It doesnt seem to work as you explain.
For a value of 1 you expect (nearly) all the tuples and two should return
half, but that not what I'm finding.
galore=> select count(*) from topten where room='HI';
count
-----
14
(1 row)
galore=> SELECT * FROM topten WHERE room='HE' and oidrand(topten.oid, 1);
type|data |norder|room |grp
----+-------------------------+------+------+---
B |0764552503 | 1|HE |
B |0751327190 | 1|HE |
B |0718144392 | |HE |
B |0500280754 | |HE |
B |0028610091 | 1|HE |
(5 rows)
galore=> SELECT * FROM topten WHERE room='HE' and oidrand(topten.oid, 2);
type|data |norder|room |grp
----+-------------------------+------+------+---
B |0764552503 | 1|HE |
B |0751327190 | 1|HE |
B |0718144392 | |HE |
(3 rows)
galore=> SELECT * FROM topten WHERE room='HE' and oidrand(topten.oid, 7);
type|data |norder|room |grp
----+-------------------------+------+------+---
B |0751327190 | 1|HE |
B |0718144392 | |HE |
(2 rows)
--
thorNET - Internet Consultancy, Services & Training
Phone: 01454 854413
Fax: 01454 854412
http://www.thornet.co.uk
From | Date | Subject | |
---|---|---|---|
Next Message | Poul L. Christiansen | 2000-07-25 08:42:41 | Re: Describe structure. |
Previous Message | Alex Bolenok | 2000-07-25 07:15:50 | Re: ROLLBACK automatically |