Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 5fea23694c765462b86d6ddf74461eab > files > 957

postgresql9.6-docs-9.6.22-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>tsm_system_rows</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.6.22 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Additional Supplied Modules"
HREF="contrib.html"><LINK
REL="PREVIOUS"
TITLE="tsearch2"
HREF="tsearch2.html"><LINK
REL="NEXT"
TITLE="tsm_system_time"
HREF="tsm-system-time.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2021-05-18T09:16:10"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="4"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.6.22 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="tsearch2"
HREF="tsearch2.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="contrib.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Appendix F. Additional Supplied Modules</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="tsm_system_time"
HREF="tsm-system-time.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="TSM-SYSTEM-ROWS"
>F.42. tsm_system_rows</A
></H1
><P
>  The <TT
CLASS="FILENAME"
>tsm_system_rows</TT
> module provides the table sampling method
  <TT
CLASS="LITERAL"
>SYSTEM_ROWS</TT
>, which can be used in
  the <TT
CLASS="LITERAL"
>TABLESAMPLE</TT
> clause of a <A
HREF="sql-select.html"
>SELECT</A
>
  command.
 </P
><P
>  This table sampling method accepts a single integer argument that is the
  maximum number of rows to read.  The resulting sample will always contain
  exactly that many rows, unless the table does not contain enough rows, in
  which case the whole table is selected.
 </P
><P
>  Like the built-in <TT
CLASS="LITERAL"
>SYSTEM</TT
> sampling
  method, <TT
CLASS="LITERAL"
>SYSTEM_ROWS</TT
> 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 requested.
 </P
><P
>  <TT
CLASS="LITERAL"
>SYSTEM_ROWS</TT
> does not support
  the <TT
CLASS="LITERAL"
>REPEATABLE</TT
> clause.
 </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN144763"
>F.42.1. Examples</A
></H2
><P
>   Here is an example of selecting a sample of a table with
   <TT
CLASS="LITERAL"
>SYSTEM_ROWS</TT
>.  First install the extension:
  </P
><PRE
CLASS="PROGRAMLISTING"
>CREATE EXTENSION tsm_system_rows;</PRE
><P
>   Then you can use it in a <TT
CLASS="COMMAND"
>SELECT</TT
> command, for instance:

</P><PRE
CLASS="PROGRAMLISTING"
>SELECT * FROM my_table TABLESAMPLE SYSTEM_ROWS(100);</PRE
><P>
  </P
><P
>   This command will return a sample of 100 rows from the
   table <TT
CLASS="STRUCTNAME"
>my_table</TT
> (unless the table does not have 100
   visible rows, in which case all its rows are returned).
  </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="tsearch2.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="tsm-system-time.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>tsearch2</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="contrib.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>tsm_system_time</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>