1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-22 21:53:06 +03:00
Files
postgres/doc/src/sgml/tsm-system-rows.sgml
Alvaro Herrera e86c8b728f Describe each contrib module in its SGML section title
The original titles only had the module name, which is not very useful
when scanning the list.  By adding a very brief description to each
title, the table of contents becomes friendlier.

Also amend the introduction in the "additional modules" appendix, using
the word "Extension" more extensively.  Nowadays, almost all contrib
modules are extensions, so this is also helpful.

Author: Karl O. Pinc <kop@karlpinc.com>
Reviewed-by: Brar Piening <brar@gmx.de>
Discussion: https://postgr.es/m/20230102180015.372995a9@slate.karlpinc.com
2023-01-20 20:01:59 +01:00

71 lines
2.1 KiB
Plaintext

<!-- doc/src/sgml/tsm-system-rows.sgml -->
<sect1 id="tsm-system-rows" xreflabel="tsm_system_rows">
<title>tsm_system_rows &mdash;
the <literal>SYSTEM_ROWS</literal> sampling method for <literal>TABLESAMPLE</literal></title>
<indexterm zone="tsm-system-rows">
<primary>tsm_system_rows</primary>
</indexterm>
<para>
The <filename>tsm_system_rows</filename> module provides the table sampling method
<literal>SYSTEM_ROWS</literal>, which can be used in
the <literal>TABLESAMPLE</literal> clause of a <link linkend="sql-select"><command>SELECT</command></link>
command.
</para>
<para>
This 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.
</para>
<para>
Like the built-in <literal>SYSTEM</literal> sampling
method, <literal>SYSTEM_ROWS</literal> 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.
</para>
<para>
<literal>SYSTEM_ROWS</literal> does not support
the <literal>REPEATABLE</literal> clause.
</para>
<para>
This module is considered <quote>trusted</quote>, that is, it can be
installed by non-superusers who have <literal>CREATE</literal> privilege
on the current database.
</para>
<sect2 id="tsm-system-rows-examples">
<title>Examples</title>
<para>
Here is an example of selecting a sample of a table with
<literal>SYSTEM_ROWS</literal>. First install the extension:
</para>
<programlisting>
CREATE EXTENSION tsm_system_rows;
</programlisting>
<para>
Then you can use it in a <command>SELECT</command> command, for instance:
<programlisting>
SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);
</programlisting>
</para>
<para>
This command will return a sample of 100 rows from the
table <structname>my_table</structname> (unless the table does not have 100
visible rows, in which case all its rows are returned).
</para>
</sect2>
</sect1>