MINI MINI MANI MO
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_statistic</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.2.24 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="System Catalogs"
HREF="catalogs.html"><LINK
REL="PREVIOUS"
TITLE="pg_shseclabel"
HREF="catalog-pg-shseclabel.html"><LINK
REL="NEXT"
TITLE="pg_tablespace"
HREF="catalog-pg-tablespace.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="2017-11-06T22:43:11"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.2.24 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="pg_shseclabel"
HREF="catalog-pg-shseclabel.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 45. System Catalogs</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="pg_tablespace"
HREF="catalog-pg-tablespace.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CATALOG-PG-STATISTIC"
>45.42. <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
></A
></H1
><P
> The catalog <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> stores
statistical data about the contents of the database. Entries are
created by <A
HREF="sql-analyze.html"
>ANALYZE</A
>
and subsequently used by the query planner. Note that all the
statistical data is inherently approximate, even assuming that it
is up-to-date.
</P
><P
> Normally there is one entry, with <TT
CLASS="STRUCTFIELD"
>stainherit</TT
> =
<TT
CLASS="LITERAL"
>false</TT
>, for each table column that has been analyzed.
If the table has inheritance children, a second entry with
<TT
CLASS="STRUCTFIELD"
>stainherit</TT
> = <TT
CLASS="LITERAL"
>true</TT
> is also created. This row
represents the column's statistics over the inheritance tree, i.e.,
statistics for the data you'd see with
<TT
CLASS="LITERAL"
>SELECT <TT
CLASS="REPLACEABLE"
><I
>column</I
></TT
> FROM <TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
>*</TT
>,
whereas the <TT
CLASS="STRUCTFIELD"
>stainherit</TT
> = <TT
CLASS="LITERAL"
>false</TT
> row represents
the results of
<TT
CLASS="LITERAL"
>SELECT <TT
CLASS="REPLACEABLE"
><I
>column</I
></TT
> FROM ONLY <TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
></TT
>.
</P
><P
> <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> also stores statistical data about
the values of index expressions. These are described as if they were
actual data columns; in particular, <TT
CLASS="STRUCTFIELD"
>starelid</TT
>
references the index. No entry is made for an ordinary non-expression
index column, however, since it would be redundant with the entry
for the underlying table column. Currently, entries for index expressions
always have <TT
CLASS="STRUCTFIELD"
>stainherit</TT
> = <TT
CLASS="LITERAL"
>false</TT
>.
</P
><P
> Since different kinds of statistics might be appropriate for different
kinds of data, <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> is designed not
to assume very much about what sort of statistics it stores. Only
extremely general statistics (such as nullness) are given dedicated
columns in <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
>. Everything else
is stored in <SPAN
CLASS="QUOTE"
>"slots"</SPAN
>, which are groups of associated columns
whose content is identified by a code number in one of the slot's columns.
For more information see
<TT
CLASS="FILENAME"
>src/include/catalog/pg_statistic.h</TT
>.
</P
><P
> <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> should not be readable by the
public, since even statistical information about a table's contents
might be considered sensitive. (Example: minimum and maximum values
of a salary column might be quite interesting.)
<A
HREF="view-pg-stats.html"
><TT
CLASS="STRUCTNAME"
>pg_stats</TT
></A
>
is a publicly readable view on
<TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> that only exposes information
about those tables that are readable by the current user.
</P
><DIV
CLASS="TABLE"
><A
NAME="AEN92716"
></A
><P
><B
>Table 45-42. <TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> Columns</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Type</TH
><TH
>References</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>starelid</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-class.html"
><TT
CLASS="STRUCTNAME"
>pg_class</TT
></A
>.oid</TT
></TD
><TD
>The table or index that the described column belongs to</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>staattnum</TT
></TD
><TD
><TT
CLASS="TYPE"
>int2</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-attribute.html"
><TT
CLASS="STRUCTNAME"
>pg_attribute</TT
></A
>.attnum</TT
></TD
><TD
>The number of the described column</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stainherit</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
> </TD
><TD
>If true, the stats include inheritance child columns, not just the
values in the specified relation</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stanullfrac</TT
></TD
><TD
><TT
CLASS="TYPE"
>float4</TT
></TD
><TD
> </TD
><TD
>The fraction of the column's entries that are null</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stawidth</TT
></TD
><TD
><TT
CLASS="TYPE"
>int4</TT
></TD
><TD
> </TD
><TD
>The average stored width, in bytes, of nonnull entries</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stadistinct</TT
></TD
><TD
><TT
CLASS="TYPE"
>float4</TT
></TD
><TD
> </TD
><TD
>The number of distinct nonnull data values in the column.
A value greater than zero is the actual number of distinct values.
A value less than zero is the negative of a multiplier for the number
of rows in the table; for example, a column in which about 80% of the
values are nonnull and each nonnull value appears about twice on
average could be represented by <TT
CLASS="STRUCTFIELD"
>stadistinct</TT
> = -0.4.
A zero value means the number of distinct values is unknown.
</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stakind<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
></TT
></TD
><TD
><TT
CLASS="TYPE"
>int2</TT
></TD
><TD
> </TD
><TD
> A code number indicating the kind of statistics stored in the
<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
>th <SPAN
CLASS="QUOTE"
>"slot"</SPAN
> of the
<TT
CLASS="STRUCTNAME"
>pg_statistic</TT
> row.
</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>staop<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
></TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-operator.html"
><TT
CLASS="STRUCTNAME"
>pg_operator</TT
></A
>.oid</TT
></TD
><TD
> An operator used to derive the statistics stored in the
<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
>th <SPAN
CLASS="QUOTE"
>"slot"</SPAN
>. For example, a
histogram slot would show the <TT
CLASS="LITERAL"
><</TT
> operator
that defines the sort order of the data.
</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stanumbers<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
></TT
></TD
><TD
><TT
CLASS="TYPE"
>float4[]</TT
></TD
><TD
> </TD
><TD
> Numerical statistics of the appropriate kind for the
<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
>th <SPAN
CLASS="QUOTE"
>"slot"</SPAN
>, or null if the slot
kind does not involve numerical values
</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>stavalues<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
></TT
></TD
><TD
><TT
CLASS="TYPE"
>anyarray</TT
></TD
><TD
> </TD
><TD
> Column data values of the appropriate kind for the
<TT
CLASS="REPLACEABLE"
><I
>N</I
></TT
>th <SPAN
CLASS="QUOTE"
>"slot"</SPAN
>, or null if the slot
kind does not store any data values. Each array's element
values are actually of the specific column's data type, or a related
type such as an array's element type, so there is no way to define
these columns' type more specifically than <TT
CLASS="TYPE"
>anyarray</TT
>.
</TD
></TR
></TBODY
></TABLE
></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="catalog-pg-shseclabel.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="catalog-pg-tablespace.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_shseclabel</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_tablespace</TT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
OHA YOOOO