At update of non-LP_NORMAL TID, fail instead of corrupting page header.
[pgsql.git] / doc / src / sgml / tsm-system-time.sgml
blob05c6be0caca0cbc03fda6394142151ff78596d9f
1 <!-- doc/src/sgml/tsm-system-time.sgml -->
3 <sect1 id="tsm-system-time" xreflabel="tsm_system_time">
4 <title>tsm_system_time &mdash;
5 the <literal>SYSTEM_TIME</literal> sampling method for <literal>TABLESAMPLE</literal></title>
7 <indexterm zone="tsm-system-time">
8 <primary>tsm_system_time</primary>
9 </indexterm>
11 <para>
12 The <filename>tsm_system_time</filename> module provides the table sampling method
13 <literal>SYSTEM_TIME</literal>, which can be used in
14 the <literal>TABLESAMPLE</literal> clause of a <link linkend="sql-select"><command>SELECT</command></link>
15 command.
16 </para>
18 <para>
19 This table sampling method accepts a single floating-point argument that
20 is the maximum number of milliseconds to spend reading the table. This
21 gives you direct control over how long the query takes, at the price that
22 the size of the sample becomes hard to predict. The resulting sample will
23 contain as many rows as could be read in the specified time, unless the
24 whole table has been read first.
25 </para>
27 <para>
28 Like the built-in <literal>SYSTEM</literal> sampling
29 method, <literal>SYSTEM_TIME</literal> performs block-level sampling, so
30 that the sample is not completely random but may be subject to clustering
31 effects, especially if only a small number of rows are selected.
32 </para>
34 <para>
35 <literal>SYSTEM_TIME</literal> does not support
36 the <literal>REPEATABLE</literal> clause.
37 </para>
39 <para>
40 This module is considered <quote>trusted</quote>, that is, it can be
41 installed by non-superusers who have <literal>CREATE</literal> privilege
42 on the current database.
43 </para>
45 <sect2 id="tsm-system-time-examples">
46 <title>Examples</title>
48 <para>
49 Here is an example of selecting a sample of a table with
50 <literal>SYSTEM_TIME</literal>. First install the extension:
51 </para>
53 <programlisting>
54 CREATE EXTENSION tsm_system_time;
55 </programlisting>
57 <para>
58 Then you can use it in a <command>SELECT</command> command, for instance:
60 <programlisting>
61 SELECT * FROM my_table TABLESAMPLE SYSTEM_TIME(1000);
62 </programlisting>
63 </para>
65 <para>
66 This command will return as large a sample of <structname>my_table</structname> as
67 it can read in 1 second (1000 milliseconds). Of course, if the whole
68 table can be read in under 1 second, all its rows will be returned.
69 </para>
70 </sect2>
72 </sect1>