|
| 1 | +<!-- doc/src/sgml/tsm-system-rows.sgml --> |
| 2 | + |
| 3 | +<sect1 id="tsm-system-rows" xreflabel="tsm_system_rows"> |
| 4 | + <title>tsm_system_rows</title> |
| 5 | + |
| 6 | + <indexterm zone="tsm-system-rows"> |
| 7 | + <primary>tsm_system_rows</primary> |
| 8 | + </indexterm> |
| 9 | + |
| 10 | + <para> |
| 11 | + The <filename>tsm_system_rows</> module provides the tablesample method |
| 12 | + <literal>SYSTEM_ROWS</literal>, which can be used inside the |
| 13 | + <command>TABLESAMPLE</command> clause of a <command>SELECT</command>. |
| 14 | + </para> |
| 15 | + |
| 16 | + <para> |
| 17 | + This tablesample method uses a linear probing algorithm to read sample |
| 18 | + of a table and uses actual number of rows as limit (unlike the |
| 19 | + <literal>SYSTEM</literal> tablesample method which limits by percentage |
| 20 | + of a table). |
| 21 | + </para> |
| 22 | + |
| 23 | + <sect2> |
| 24 | + <title>Examples</title> |
| 25 | + |
| 26 | + <para> |
| 27 | + Here is an example of selecting sample of a table with |
| 28 | + <literal>SYSTEM_ROWS</>. First install the extension: |
| 29 | + </para> |
| 30 | + |
| 31 | +<programlisting> |
| 32 | +CREATE EXTENSION tsm_system_rows; |
| 33 | +</programlisting> |
| 34 | + |
| 35 | + <para> |
| 36 | + Then you can use it in <command>SELECT</command> command same way as other |
| 37 | + tablesample methods: |
| 38 | + |
| 39 | +<programlisting> |
| 40 | +SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100); |
| 41 | +</programlisting> |
| 42 | + </para> |
| 43 | + |
| 44 | + <para> |
| 45 | + The above command will return a sample of 100 rows from the table my_table |
| 46 | + (less if the table does not have 100 visible rows). |
| 47 | + </para> |
| 48 | + </sect2> |
| 49 | + |
| 50 | +</sect1> |