Re: Gsoc2012 idea, tablesample - Mailing list pgsql-hackers

From Sandro Santilli
Subject Re: Gsoc2012 idea, tablesample
Date
Msg-id 20120424073136.GF7891@gnash
Whole thread Raw
In response to Re: Gsoc2012 idea, tablesample  (Sandro Santilli <strk@keybit.net>)
Responses Re: Gsoc2012 idea, tablesample  (Ants Aasma <ants@cybertec.at>)
List pgsql-hackers
On Tue, Apr 24, 2012 at 08:49:26AM +0200, Sandro Santilli wrote:
> On Mon, Apr 23, 2012 at 08:34:44PM +0300, Ants Aasma wrote:

> > SELECT (SELECT reservoir_sample(some_table, 50) AS samples
> >    FROM some_table WHERE ctid =~ ANY (rnd_pgtids))
> > FROM random_pages('some_table', 50) AS rnd_pgtids;
> 
> But I don't understand the reservoir_sample call, what is it supposed to do ?

Ok got it, that was probably to avoid:
ERROR:  more than one row returned by a subquery used as an expression

But this also works nicely:
SELECT * FROM lots_of_pointsWHERE ctid = ANY ( ARRAY[(SELECT random_tids('lots_of_points', 100000))] );

and still uses tidscan.

The advanced TID operator would be for random_tids to only return pages rather
than full tids...

--strk; 
 ,------o-.  |   __/  |    Delivering high quality PostGIS 2.0 ! |  / 2.0 |    http://strk.keybit.net -
http://vizzuality.com`-o------'
 



pgsql-hackers by date:

Previous
From: Nikhil Sontakke
Date:
Subject: Re: B-tree page deletion boundary cases
Next
From: Boszormenyi Zoltan
Date:
Subject: PL/PGSQL bug in handling composite types