Home Explore Blog CI



postgresql

11th chunk of `doc/src/sgml/pgstatstatements.sgml`
f4b15a3b08c8fd22ec0c6971d3424e08533b4eb3474f12660000000100000fc2
 <variablelist>
   <varlistentry>
    <term>
     <function>pg_stat_statements_reset(userid Oid, dbid Oid, queryid
     bigint, minmax_only boolean) returns timestamp with time zone</function>
     <indexterm>
      <primary>pg_stat_statements_reset</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>pg_stat_statements_reset</function> discards statistics
      gathered so far by <filename>pg_stat_statements</filename> corresponding
      to the specified <structfield>userid</structfield>, <structfield>dbid</structfield>
      and <structfield>queryid</structfield>.  If any of the parameters are not
      specified, the default value <literal>0</literal>(invalid) is used for
      each of them and the statistics that match with other parameters will be
      reset.  If no parameter is specified or all the specified parameters are
      <literal>0</literal>(invalid), it will discard all statistics.
      If all statistics in the <filename>pg_stat_statements</filename>
      view are discarded, it will also reset the statistics in the
      <structname>pg_stat_statements_info</structname> view.
      When <structfield>minmax_only</structfield> is <literal>true</literal> only the
      values of minimum and maximum planning and execution time will be reset (i.e.
      <structfield>min_plan_time</structfield>, <structfield>max_plan_time</structfield>,
      <structfield>min_exec_time</structfield> and <structfield>max_exec_time</structfield>
      fields). The default value for <structfield>minmax_only</structfield> parameter is
      <literal>false</literal>. Time of last min/max reset performed is shown in
      <structfield>minmax_stats_since</structfield> field of the
      <structname>pg_stat_statements</structname> view.
      This function returns the time of a reset. This time is saved to
      <structfield>stats_reset</structfield> field of
      <structname>pg_stat_statements_info</structname> view or to
      <structfield>minmax_stats_since</structfield> field of the
      <structname>pg_stat_statements</structname> view if the corresponding reset was
      actually performed.
      By default, this function can only be executed by superusers.
      Access may be granted to others using <command>GRANT</command>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>pg_stat_statements(showtext boolean) returns setof record</function>
     <indexterm>
      <primary>pg_stat_statements</primary>
      <secondary>function</secondary>
     </indexterm>
    </term>

    <listitem>
     <para>
      The <structname>pg_stat_statements</structname> view is defined in
      terms of a function also named <function>pg_stat_statements</function>.
      It is possible for clients to call
      the <function>pg_stat_statements</function> function directly, and by
      specifying <literal>showtext := false</literal> have query text be
      omitted (that is, the <literal>OUT</literal> argument that corresponds
      to the view's <structfield>query</structfield> column will return nulls).  This
      feature is intended to support external tools that might wish to avoid
      the overhead of repeatedly retrieving query texts of indeterminate
      length.  Such tools can instead cache the first query text observed
      for each entry themselves, since that is
      all <filename>pg_stat_statements</filename> itself does, and then retrieve
      query texts only as needed.  Since the server stores query texts in a
      file, this approach may reduce physical I/O for repeated examination
      of the <structname>pg_stat_statements</structname> data.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </sect2>

 <sect2 id="pgstatstatements-config-params">
  <title>Configuration Parameters</title>

  <variablelist>
   <varlistentry>
    <term>
     <varname>pg_stat_statements.max</varname> (<type>integer</type>)
     <indexterm>
      <primary><varname>pg_stat_statements.max</varname>

Title: pg_stat_statements Functions and Configuration
Summary
The pg_stat_statements module provides two main functions: pg_stat_statements_reset, which discards gathered statistics based on user ID, database ID, and query ID, and pg_stat_statements, which returns a set of records from the pg_stat_statements view, with an option to omit query text for reduced overhead, and several configuration parameters to control its behavior.