]> begriffs open source - ai-pg/blob - full-docs/txt/tsm-system-rows.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / tsm-system-rows.txt
1
2 F.46. tsm_system_rows — the SYSTEM_ROWS sampling method for TABLESAMPLE #
3
4    F.46.1. Examples
5
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
8    command.
9
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.
14
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.
19
20    SYSTEM_ROWS does not support the REPEATABLE clause.
21
22    This module is considered “trusted”, that is, it can be installed by
23    non-superusers who have CREATE privilege on the current database.
24
25 F.46.1. Examples #
26
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;
30
31    Then you can use it in a SELECT command, for instance:
32 SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);
33
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
36    rows are returned).