]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/tsm-system-rows.html
PG 18 docs from https://ftp.postgresql.org/pub/source/v18.0/postgresql-18.0-docs...
[ai-pg] / full-docs / src / sgml / html / tsm-system-rows.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.46. tsm_system_rows — the SYSTEM_ROWS sampling method for TABLESAMPLE</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="test-decoding.html" title="F.45. test_decoding — SQL-based test/example module for WAL logical decoding" /><link rel="next" href="tsm-system-time.html" title="F.47. tsm_system_time — the SYSTEM_TIME sampling method for TABLESAMPLE" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.46. tsm_system_rows —
3    the <code class="literal">SYSTEM_ROWS</code> sampling method for <code class="literal">TABLESAMPLE</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="test-decoding.html" title="F.45. test_decoding — SQL-based test/example module for WAL logical decoding">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules and Extensions</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="tsm-system-time.html" title="F.47. tsm_system_time —&#10;   the SYSTEM_TIME sampling method for TABLESAMPLE">Next</a></td></tr></table><hr /></div><div class="sect1" id="TSM-SYSTEM-ROWS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.46. tsm_system_rows —
4    the <code class="literal">SYSTEM_ROWS</code> sampling method for <code class="literal">TABLESAMPLE</code> <a href="#TSM-SYSTEM-ROWS" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="tsm-system-rows.html#TSM-SYSTEM-ROWS-EXAMPLES">F.46.1. Examples</a></span></dt></dl></div><a id="id-1.11.7.56.2" class="indexterm"></a><p>
5   The <code class="filename">tsm_system_rows</code> module provides the table sampling method
6   <code class="literal">SYSTEM_ROWS</code>, which can be used in
7   the <code class="literal">TABLESAMPLE</code> clause of a <a class="link" href="sql-select.html" title="SELECT"><code class="command">SELECT</code></a>
8   command.
9  </p><p>
10   This table sampling method accepts a single integer argument that is the
11   maximum number of rows to read.  The resulting sample will always contain
12   exactly that many rows, unless the table does not contain enough rows, in
13   which case the whole table is selected.
14  </p><p>
15   Like the built-in <code class="literal">SYSTEM</code> sampling
16   method, <code class="literal">SYSTEM_ROWS</code> performs block-level sampling, so
17   that the sample is not completely random but may be subject to clustering
18   effects, especially if only a small number of rows are requested.
19  </p><p>
20   <code class="literal">SYSTEM_ROWS</code> does not support
21   the <code class="literal">REPEATABLE</code> clause.
22  </p><p>
23   This module is considered <span class="quote">“<span class="quote">trusted</span>”</span>, that is, it can be
24   installed by non-superusers who have <code class="literal">CREATE</code> privilege
25   on the current database.
26  </p><div class="sect2" id="TSM-SYSTEM-ROWS-EXAMPLES"><div class="titlepage"><div><div><h3 class="title">F.46.1. Examples <a href="#TSM-SYSTEM-ROWS-EXAMPLES" class="id_link">#</a></h3></div></div></div><p>
27    Here is an example of selecting a sample of a table with
28    <code class="literal">SYSTEM_ROWS</code>.  First install the extension:
29   </p><pre class="programlisting">
30 CREATE EXTENSION tsm_system_rows;
31 </pre><p>
32    Then you can use it in a <code class="command">SELECT</code> command, for instance:
33
34 </p><pre class="programlisting">
35 SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);
36 </pre><p>
37   </p><p>
38    This command will return a sample of 100 rows from the
39    table <code class="structname">my_table</code> (unless the table does not have 100
40    visible rows, in which case all its rows are returned).
41   </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="test-decoding.html" title="F.45. test_decoding — SQL-based test/example module for WAL logical decoding">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="tsm-system-time.html" title="F.47. tsm_system_time —&#10;   the SYSTEM_TIME sampling method for TABLESAMPLE">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.45. test_decoding — SQL-based test/example module for WAL logical decoding </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.47. tsm_system_time —
42    the <code class="literal">SYSTEM_TIME</code> sampling method for <code class="literal">TABLESAMPLE</code></td></tr></table></div></body></html>