Tablesample and Other Methods for Getting Random Tuples
PostgreSQL’s TABLESAMPLE brings a few more advantages compared to other traditional ways for getting random tuples.
PostgreSQL’s TABLESAMPLE brings a few more advantages compared to other traditional ways for getting random tuples.
PostgreSQL 9.5 introduces support for TABLESAMPLE, an SQL SELECT clause that returns a random sample from a table.
An interesting query has been twitted by Will Leinweber from Postgres Open: — this returns a different result each time it is ran with recursive s as ( select random() union select random() from s ) select count(*) from s; I like this example: a surprising result, which can be explained by (and indeed helps to explain) CTE […]