Home Explore Blog CI



postgresql

95th chunk of `doc/src/sgml/config.sgml`
41084e2b77eb3f5387692533c128103ac3f6c0bc21170e970000000100000fa1
 </variablelist>
    </sect2>
     <sect2 id="runtime-config-query-other">
     <title>Other Planner Options</title>

     <variablelist>

     <varlistentry id="guc-default-statistics-target" xreflabel="default_statistics_target">
      <term><varname>default_statistics_target</varname> (<type>integer</type>)
      <indexterm>
       <primary><varname>default_statistics_target</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        Sets the default statistics target for table columns without
        a column-specific target set via <command>ALTER TABLE
        SET STATISTICS</command>.  Larger values increase the time needed to
        do <command>ANALYZE</command>, but might improve the quality of the
        planner's estimates. The default is 100. For more information
        on the use of statistics by the <productname>PostgreSQL</productname>
        query planner, refer to <xref linkend="planner-stats"/>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-constraint-exclusion" xreflabel="constraint_exclusion">
      <term><varname>constraint_exclusion</varname> (<type>enum</type>)
      <indexterm>
       <primary>constraint exclusion</primary>
      </indexterm>
      <indexterm>
       <primary><varname>constraint_exclusion</varname> configuration parameter</primary>
      </indexterm>
      </term>
      <listitem>
       <para>
        Controls the query planner's use of table constraints to
        optimize queries.
        The allowed values of <varname>constraint_exclusion</varname> are
        <literal>on</literal> (examine constraints for all tables),
        <literal>off</literal> (never examine constraints), and
        <literal>partition</literal> (examine constraints only for inheritance
        child tables and <literal>UNION ALL</literal> subqueries).
        <literal>partition</literal> is the default setting.
        It is often used with traditional inheritance trees to improve
        performance.
      </para>

       <para>
        When this parameter allows it for a particular table, the planner
        compares query conditions with the table's <literal>CHECK</literal>
        constraints, and omits scanning tables for which the conditions
        contradict the constraints.  For example:

<programlisting>
CREATE TABLE parent(key integer, ...);
CREATE TABLE child1000(check (key between 1000 and 1999)) INHERITS(parent);
CREATE TABLE child2000(check (key between 2000 and 2999)) INHERITS(parent);
...
SELECT * FROM parent WHERE key = 2400;
</programlisting>

        With constraint exclusion enabled, this <command>SELECT</command>
        will not scan <structname>child1000</structname> at all, improving performance.
       </para>

       <para>
        Currently, constraint exclusion is enabled by default
        only for cases that are often used to implement table partitioning via
        inheritance trees.  Turning it on for all tables imposes extra
        planning overhead that is quite noticeable on simple queries, and most
        often will yield no benefit for simple queries.  If you have no
        tables that are partitioned using traditional inheritance, you might
        prefer to turn it off entirely.  (Note that the equivalent feature for
        partitioned tables is controlled by a separate parameter,
        <xref linkend="guc-enable-partition-pruning"/>.)
       </para>

       <para>
        Refer to <xref linkend="ddl-partitioning-constraint-exclusion"/> for
        more information on using constraint exclusion to implement
        partitioning.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry id="guc-cursor-tuple-fraction" xreflabel="cursor_tuple_fraction">
      <term><varname>cursor_tuple_fraction</varname> (<type>floating point</type>)
      <indexterm>
       <primary><varname>cursor_tuple_fraction</varname> configuration parameter</primary>
      </indexterm>

Title: Other Planner Options: Statistics Target, Constraint Exclusion, and Cursor Tuple Fraction
Summary
This section details other planner options, including `default_statistics_target`, which sets the default statistics target for table columns; `constraint_exclusion`, which controls the query planner's use of table constraints to optimize queries; and `cursor_tuple_fraction`.