<!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 8.0.11 Documentation" HREF="index.html"><LINK REL="UP" TITLE="System Catalogs" HREF="catalogs.html"><LINK REL="PREVIOUS" TITLE="pg_shadow" HREF="catalog-pg-shadow.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="2007-02-02T03:57:22"></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" >PostgreSQL 8.0.11 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="catalog-pg-shadow.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="catalogs.html" >Fast Backward</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" >Chapter 41. System Catalogs</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A HREF="catalogs.html" >Fast Forward</A ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="top" ><A 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" >41.27. <TT CLASS="STRUCTNAME" >pg_statistic</TT ></A ></H1 ><A NAME="AEN54488" ></A ><P > The catalog <TT CLASS="STRUCTNAME" >pg_statistic</TT > stores statistical data about the contents of the database. Entries are created by <TT CLASS="COMMAND" >ANALYZE</TT > and subsequently used by the query planner. There is one entry for each table column that has been analyzed. Note that all the statistical data is inherently approximate, even assuming that it is up-to-date. </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. </P ><P > Since different kinds of statistics may 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 may 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="AEN54506" ></A ><P ><B >Table 41-27. <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" >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 fraction of the number of rows in the table (for example, a column in which values appear about twice on the average could be represented by <TT CLASS="STRUCTFIELD" >stadistinct</TT > = -0.5). 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, 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-shadow.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_shadow</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 >