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 […]
UK +44 (0)870 766 7756
US +1 650 378 1218
Stay in touch with us
Subscribe to our monthly newsletter to hear the latest developments from 2ndQuadrant and related technologies.
We’ll also send you any important news or updates that we think you’ll find useful.
We value your privacy and will not pass your details on to anyone else.