|
| 1 | +<!-- doc/src/sgml/tsm-system-time.sgml --> |
| 2 | + |
| 3 | +<sect1 id="tsm-system-time" xreflabel="tsm_system_time"> |
| 4 | + <title>tsm_system_time</title> |
| 5 | + |
| 6 | + <indexterm zone="tsm-system-time"> |
| 7 | + <primary>tsm_system_time</primary> |
| 8 | + </indexterm> |
| 9 | + |
| 10 | + <para> |
| 11 | + The <filename>tsm_system_time</> module provides the tablesample method |
| 12 | + <literal>SYSTEM_TIME</literal>, which can be used inside the |
| 13 | + <command>TABLESAMPLE</command> clause of a <command>SELECT</command>. |
| 14 | + </para> |
| 15 | + |
| 16 | + <para> |
| 17 | + This tablesample method uses a linear probing algorithm to read sample |
| 18 | + of a table and uses time in milliseconds as limit (unlike the |
| 19 | + <literal>SYSTEM</literal> tablesample method which limits by percentage |
| 20 | + of a table). This gives you some control over the length of execution |
| 21 | + of your query. |
| 22 | + </para> |
| 23 | + |
| 24 | + <sect2> |
| 25 | + <title>Examples</title> |
| 26 | + |
| 27 | + <para> |
| 28 | + Here is an example of selecting sample of a table with |
| 29 | + <literal>SYSTEM_TIME</>. First install the extension: |
| 30 | + </para> |
| 31 | + |
| 32 | +<programlisting> |
| 33 | +CREATE EXTENSION tsm_system_time; |
| 34 | +</programlisting> |
| 35 | + |
| 36 | + <para> |
| 37 | + Then you can use it in a <command>SELECT</command> command the same way as |
| 38 | + other tablesample methods: |
| 39 | + |
| 40 | +<programlisting> |
| 41 | +SELECT * FROM my_table TABLESAMPLE SYSTEM_TIME(1000); |
| 42 | +</programlisting> |
| 43 | + </para> |
| 44 | + |
| 45 | + <para> |
| 46 | + The above command will return as large a sample of my_table as it can read in |
| 47 | + 1 second (or less if it reads whole table faster). |
| 48 | + </para> |
| 49 | + </sect2> |
| 50 | + |
| 51 | +</sect1> |