The tsm_system_rows
module implements the SYSTEM_ROWS
table sampling method. This method is used in the TABLESAMPLE
clause of a SELECT
command.
The tsm_system_rows
module is a Greenplum Database extension.
The tsm_system_rows
module is installed when you install Greenplum Database. Before you can use any of the functions defined in the module, you must register the tsm_system_rows
extension in each database where you want to use the functions. Refer to Installing Additional Supplied Modules for more information.
The SYSTEM ROWS
table sampling method accepts a single integer argument that is the maximum number of rows to read. The resulting sample will always contain exactly that many rows, unless the table does not contain enough rows, in which case the whole table is selected.
Like the built-in SYSTEM
sampling method, SYSTEM_ROWS
performs block-level sampling, so that the sample is not completely random but may be subject to clustering effects, especially if only a small number of rows are requested.
The following command returns a sample of 75 rows from the table tableA
, unless the table does not have 75 visible rows; in this case, the command returns all table rows:
SELECT * FROM tableA TABLESAMPLE SYSTEM_ROWS(75);