1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00
Files
postgres/doc/src/sgml/tsm-system-time.sgml
Tom Lane eb67623c96 Mark some contrib modules as "trusted".
This allows these modules to be installed into a database without
superuser privileges (assuming that the DBA or sysadmin has installed
the module's files in the expected place).  You only need CREATE
privilege on the current database, which by default would be
available to the database owner.

The following modules are marked trusted:

btree_gin
btree_gist
citext
cube
dict_int
earthdistance
fuzzystrmatch
hstore
hstore_plperl
intarray
isn
jsonb_plperl
lo
ltree
pg_trgm
pgcrypto
seg
tablefunc
tcn
tsm_system_rows
tsm_system_time
unaccent
uuid-ossp

In the future we might mark some more modules trusted, but there
seems to be no debate about these, and on the whole it seems wise
to be conservative with use of this feature to start out with.

Discussion: https://postgr.es/m/32315.1580326876@sss.pgh.pa.us
2020-02-13 15:02:35 -05:00

72 lines
2.1 KiB
Plaintext

<!-- doc/src/sgml/tsm-system-time.sgml -->
<sect1 id="tsm-system-time" xreflabel="tsm_system_time">
<title>tsm_system_time</title>
<indexterm zone="tsm-system-time">
<primary>tsm_system_time</primary>
</indexterm>
<para>
The <filename>tsm_system_time</filename> module provides the table sampling method
<literal>SYSTEM_TIME</literal>, which can be used in
the <literal>TABLESAMPLE</literal> clause of a <xref linkend="sql-select"/>
command.
</para>
<para>
This table sampling method accepts a single floating-point argument that
is the maximum number of milliseconds to spend reading the table. This
gives you direct control over how long the query takes, at the price that
the size of the sample becomes hard to predict. The resulting sample will
contain as many rows as could be read in the specified time, unless the
whole table has been read first.
</para>
<para>
Like the built-in <literal>SYSTEM</literal> sampling
method, <literal>SYSTEM_TIME</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 selected.
</para>
<para>
<literal>SYSTEM_TIME</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>
<title>Examples</title>
<para>
Here is an example of selecting a sample of a table with
<literal>SYSTEM_TIME</literal>. First install the extension:
</para>
<programlisting>
CREATE EXTENSION tsm_system_time;
</programlisting>
<para>
Then you can use it in a <command>SELECT</command> command, for instance:
<programlisting>
SELECT * FROM my_table TABLESAMPLE SYSTEM_TIME(1000);
</programlisting>
</para>
<para>
This command will return as large a sample of <structname>my_table</structname> as
it can read in 1 second (1000 milliseconds). Of course, if the whole
table can be read in under 1 second, all its rows will be returned.
</para>
</sect2>
</sect1>