2 F.46. tsm_system_rows — the SYSTEM_ROWS sampling method for TABLESAMPLE #
6 The tsm_system_rows module provides the table sampling method
7 SYSTEM_ROWS, which can be used in the TABLESAMPLE clause of a SELECT
10 This table sampling method accepts a single integer argument that is
11 the maximum number of rows to read. The resulting sample will always
12 contain exactly that many rows, unless the table does not contain
13 enough rows, in which case the whole table is selected.
15 Like the built-in SYSTEM sampling method, SYSTEM_ROWS performs
16 block-level sampling, so that the sample is not completely random but
17 may be subject to clustering effects, especially if only a small number
18 of rows are requested.
20 SYSTEM_ROWS does not support the REPEATABLE clause.
22 This module is considered “trusted”, that is, it can be installed by
23 non-superusers who have CREATE privilege on the current database.
27 Here is an example of selecting a sample of a table with SYSTEM_ROWS.
28 First install the extension:
29 CREATE EXTENSION tsm_system_rows;
31 Then you can use it in a SELECT command, for instance:
32 SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);
34 This command will return a sample of 100 rows from the table my_table
35 (unless the table does not have 100 visible rows, in which case all its