Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it? - Mailing list pgsql-hackers

From Petr Jelinek
Subject Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it?
Date
Msg-id 55A7B6AA.20008@2ndquadrant.com
Whole thread Raw
In response to TABLESAMPLE doesn't actually satisfy the SQL spec, does it?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2015-07-12 18:02, Tom Lane wrote:
>
> A possible way around this problem is to redefine the sampling rule so
> that it is not history-dependent but depends only on the tuple TIDs.
> For instance, one could hash the TID of a candidate tuple, xor that with
> a hash of the seed being used for the current query, and then select the
> tuple if (hash/MAXINT) < P.
>

That would work for bernoulli for physical tuples, yes. Only thing that 
worries me is future extensibility for data sources that only provide 
virtual tuples.

--  Petr Jelinek                  http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Volatility of pg_xact_commit_timestamp() and pg_last_committed_xact()
Next
From: Tom Lane
Date:
Subject: Re: TABLESAMPLE patch is really in pretty sad shape