Home Explore Blog CI



postgresql

91th chunk of `doc/src/sgml/catalogs.sgml`
07d2fcaa8d3c2ecc669c9d7e3112a4d5c26ffc71cb0a19fe0000000100000fa3
 references.  This is a list with one element per expression.
       Null if all statistics object attributes are simple references.
      </para></entry>
     </row>

    </tbody>
   </tgroup>
  </table>

  <para>
   The <structname>pg_statistic_ext</structname> entry is filled in
   completely during <link linkend="sql-createstatistics"><command>CREATE STATISTICS</command></link>, but the actual
   statistical values are not computed then.
   Subsequent <link linkend="sql-analyze"><command>ANALYZE</command></link> commands compute the desired values
   and populate an entry in the
   <link linkend="catalog-pg-statistic-ext-data"><structname>pg_statistic_ext_data</structname></link>
   catalog.
  </para>
 </sect1>

 <sect1 id="catalog-pg-statistic-ext-data">
  <title><structname>pg_statistic_ext_data</structname></title>

  <indexterm zone="catalog-pg-statistic-ext">
   <primary>pg_statistic_ext_data</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_statistic_ext_data</structname>
   holds data for extended planner statistics defined in
   <link linkend="catalog-pg-statistic-ext"><structname>pg_statistic_ext</structname></link>.
   Each row in this catalog corresponds to a <firstterm>statistics object</firstterm>
   created with <link linkend="sql-createstatistics"><command>CREATE STATISTICS</command></link>.
  </para>

  <para>
   Normally there is one entry, with <structfield>stxdinherit</structfield> =
   <literal>false</literal>, for each statistics object that has been analyzed.
   If the table has inheritance children or partitions, a second entry with
   <structfield>stxdinherit</structfield> = <literal>true</literal> is also created.
   This row represents the statistics object over the inheritance tree, i.e.,
   statistics for the data you'd see with
   <literal>SELECT * FROM <replaceable>table</replaceable>*</literal>,
   whereas the <structfield>stxdinherit</structfield> = <literal>false</literal> row
   represents the results of
   <literal>SELECT * FROM ONLY <replaceable>table</replaceable></literal>.
  </para>

  <para>
   Like <link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link>,
   <structname>pg_statistic_ext_data</structname> should not be
   readable by the public, since the contents might be considered sensitive.
   (Example: most common combinations of values in columns might be quite
   interesting.)
   <link linkend="view-pg-stats-ext"><structname>pg_stats_ext</structname></link>
   is a publicly readable view
   on <structname>pg_statistic_ext_data</structname> (after joining
   with <link linkend="catalog-pg-statistic-ext"><structname>pg_statistic_ext</structname></link>) that only exposes
   information about tables the current user owns.
  </para>

  <table>
   <title><structname>pg_statistic_ext_data</structname> Columns</title>
   <tgroup cols="1">
    <thead>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       Column Type
      </para>
      <para>
       Description
      </para></entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>stxoid</structfield> <type>oid</type>
       (references <link linkend="catalog-pg-statistic-ext"><structname>pg_statistic_ext</structname></link>.<structfield>oid</structfield>)
      </para>
      <para>
       Extended statistics object containing the definition for this data
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>stxdinherit</structfield> <type>bool</type>
      </para>
      <para>
       If true, the stats include values from child tables, not just the
       values in the specified relation
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>stxdndistinct</structfield> <type>pg_ndistinct</type>
      </para>

Title: pg_statistic_ext_data Catalog Details
Summary
The `pg_statistic_ext_data` catalog stores the actual statistical data for extended statistics objects defined in `pg_statistic_ext`. Each row corresponds to a statistics object created with `CREATE STATISTICS`. For tables with inheritance, there can be two entries: one for the table only (`stxdinherit` = false) and one for the entire inheritance tree (`stxdinherit` = true). Direct access to `pg_statistic_ext_data` is restricted due to sensitive information; the `pg_stats_ext` view provides a publicly readable interface for authorized users. The catalog includes columns such as `stxoid` (referencing the `pg_statistic_ext` object) and `stxdinherit` (indicating inheritance inclusion).