SAMPLE
The SAMPLE clause allows you to run the query on a sample from the base table. This can significantly speed up processing of queries, at the expense of accuracy in the result. Samples can also be used to quickly see a snapshot of the data when exploring a dataset. The sample clause is applied right after anything in the FROM clause (i.e., after any joins, but before the WHERE clause or any aggregates). See the SAMPLE page for more information.
Examples
Select a sample of 1% of the addresses table using default (system) sampling:
SQL
SELECT *FROM addressesUSING SAMPLE 1%;Select a sample of 1% of the addresses table using bernoulli sampling:
SQL
SELECT *FROM addressesUSING SAMPLE 1% (bernoulli);Select a sample of 10 rows from the subquery:
SQL
SELECT *FROM (SELECT * FROM addresses)USING SAMPLE 10 ROWS;address | city | street_name | income | zip | country | population | number1 | number2 -----------------+----------+-------------+--------+------------+---------+------------+---------+--------- 111 Birch Ln | Lakeside | Birch Ln | 70000 | 11111 | US | 50 | 3 | 30 111 Birch Ln | Lakeside | Birch Ln | 80000 | 11111-0001 | US | 50 | 4 | 40 111 Birch Ln | Linden | Birch Ln | 60000 | 11111 | NL | 100 | 2 | 20 123 Spruce Blvd | Linden | Spruce Blvd | 50000 | 11111 | NL | 100 | 1 | 10 5 Pond Road | Mallard | Pond Road | 90000 | 22222 | UK | 25 | 5 | 50 9 Lake View | Mallard | Lake View | 40000 | 33333 | UK | 25 | 6 | 60
Syntax
Syntax