バージョンごとのドキュメント一覧

F.47. tsm_system_time — TABLESAMPLEに対するSYSTEM_TIMEサンプリングメソッド #

<title>tsm_system_time &mdash; the <literal>SYSTEM_TIME</literal> sampling method for <literal>TABLESAMPLE</literal></title>

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 <link linkend="sql-select"><command>SELECT</command></link> command. tsm_system_timeモジュールはSYSTEM_TIMEというテーブルサンプリングメソッドを提供します。 これはSELECTコマンドのTABLESAMPLE句で利用できます。

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. このテーブルサンプリングメソッドはテーブルを読み込みのに消費する最大ミリ秒を指定する浮動小数点の引数を1つ取ります。 これにより、サンプルのサイズを予測するのが難しくなる代わりに、問い合わせに要する時間に関する直接的な制御が得られます。 結果のサンプルには、指定した時間内に読み込めただけの数の行が含まれます。 ただし、テーブル全体を先に読み終わった時は除きます。

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. 組み込みのSYSTEMサンプリングメソッドと同様、SYSTEM_TIMEはブロックレベルのサンプリングを行うため、サンプルは完全にはランダムではなく、特にごく少数の行がSELECTされたときはクラスタリングの影響を受けます。

<literal>SYSTEM_TIME</literal> does not support the <literal>REPEATABLE</literal> clause. SYSTEM_TIMEREPEATABLE句をサポートしません。

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. このモジュールはtrustedと見なされます。つまり、現在のデータベースに対してCREATE権限を持つ非スーパーユーザがインストールできます。

F.47.1. 例 #

<title>Examples</title>

Here is an example of selecting a sample of a table with <literal>SYSTEM_TIME</literal>. First install the extension: 以下にSYSTEM_TIMEを使ってテーブルのサンプルをSELECTする例を示します。 まず、拡張をインストールします。

CREATE EXTENSION tsm_system_time;

Then you can use it in a <command>SELECT</command> command, for instance: これで、例えば以下のようにSELECTコマンドを使うことができます。

SELECT * FROM my_table TABLESAMPLE SYSTEM_TIME(1000);

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. このコマンドは1秒(1000ミリ秒)の間にmy_tableから読み込めるだけのサンプルを返します。 もちろん、テーブル全体が1秒いないに読み込めるときは、すべての行が返されます。