Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/explain.sgml`
2f94b49be2a73eed70977599813bda9297262de41ccb21690000000100000fa8
 <literal>LIMIT</literal> clause,
   the planner makes an appropriate interpolation between the endpoint
   costs to estimate which plan is really the cheapest.
  </para>

  <para>
   The <literal>ANALYZE</literal> option causes the statement to be actually
   executed, not only planned.  Then actual run time statistics are added to
   the display, including the total elapsed time expended within each plan
   node (in milliseconds) and the total number of rows it actually returned.
   This is useful for seeing whether the planner's estimates
   are close to reality.
  </para>

  <important>
   <para>
    Keep in mind that the statement is actually executed when
    the <literal>ANALYZE</literal> option is used.  Although
    <command>EXPLAIN</command> will discard any output that a
    <command>SELECT</command> would return, other side effects of the
    statement will happen as usual.  If you wish to use
    <command>EXPLAIN ANALYZE</command> on an
    <command>INSERT</command>, <command>UPDATE</command>,
    <command>DELETE</command>, <command>MERGE</command>,
    <command>CREATE TABLE AS</command>,
    or <command>EXECUTE</command> statement
    without letting the command affect your data, use this approach:
<programlisting>
BEGIN;
EXPLAIN ANALYZE ...;
ROLLBACK;
</programlisting>
   </para>
  </important>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
   <varlistentry>
    <term><literal>ANALYZE</literal></term>
    <listitem>
     <para>
      Carry out the command and show actual run times and other statistics.
      This parameter defaults to <literal>FALSE</literal>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>VERBOSE</literal></term>
    <listitem>
     <para>
      Display additional information regarding the plan.  Specifically, include
      the output column list for each node in the plan tree, schema-qualify
      table and function names, always label variables in expressions with
      their range table alias, and always print the name of each trigger for
      which statistics are displayed.  The query identifier will also be
      displayed if one has been computed, see <xref
      linkend="guc-compute-query-id"/> for more details.  This parameter
      defaults to <literal>FALSE</literal>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>COSTS</literal></term>
    <listitem>
     <para>
      Include information on the estimated startup and total cost of each
      plan node, as well as the estimated number of rows and the estimated
      width of each row.
      This parameter defaults to <literal>TRUE</literal>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>SETTINGS</literal></term>
    <listitem>
     <para>
      Include information on configuration parameters.  Specifically, include
      options affecting query planning with value different from the built-in
      default value.  This parameter defaults to <literal>FALSE</literal>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>GENERIC_PLAN</literal></term>
    <listitem>
     <para>
      Allow the statement to contain parameter placeholders like
      <literal>$1</literal>, and generate a generic plan that does not
      depend on the values of those parameters.
      See <link linkend="sql-prepare"><command>PREPARE</command></link>
      for details about generic plans and the types of statement that
      support parameters.
      This parameter cannot be used together with <literal>ANALYZE</literal>.
      It defaults to <literal>FALSE</literal>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>BUFFERS</literal></term>
    <listitem>
     <para>
      Include information on buffer usage. Specifically, include the number of
      shared blocks hit, read, dirtied, and written, the number of local blocks
      hit, read, dirtied, and written,

Title: EXPLAIN ANALYZE Considerations and Parameters
Summary
When using EXPLAIN ANALYZE, remember that the statement is executed, so wrap INSERT, UPDATE, DELETE, MERGE, CREATE TABLE AS, or EXECUTE statements in a transaction with ROLLBACK to avoid data changes. The EXPLAIN command accepts various parameters: ANALYZE (execute and show statistics), VERBOSE (display additional plan information), COSTS (show cost estimates), SETTINGS (show configuration parameters affecting planning), GENERIC_PLAN (generate a generic plan with parameter placeholders), and BUFFERS (show buffer usage statistics).