Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/pgwalinspect.sgml`
8e5c8e97ff55971e72610df4a6d3d3b31b723d23a74dd42d0000000100000d40
 <structfield>relfilenode</structfield> parameters reference
      <link linkend="catalog-pg-tablespace"><structname>pg_tablespace</structname></link>.<structfield>oid</structfield>,
      <link linkend="catalog-pg-database"><structname>pg_database</structname></link>.<structfield>oid</structfield>, and
      <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>relfilenode</structfield>
      respectively.  The <structfield>relforknumber</structfield>
      field is the fork number within the relation for the block
      reference; see <filename>common/relpath.h</filename> for
      details.
     </para>
     <tip>
      <para>
       The <function>pg_filenode_relation</function> function (see
       <xref linkend="functions-admin-dblocation"/>) can help you to
       determine which relation was modified during original execution.
      </para>
     </tip>
     <para>
      It is possible for clients to avoid the overhead of
      materializing block data.  This may make function execution
      significantly faster.  When <replaceable>show_data</replaceable>
      is set to <literal>false</literal>, <structfield>block_data</structfield>
      and <structfield>block_fpi_data</structfield> values are omitted
      (that is, the <structfield>block_data</structfield> and
      <structfield>block_fpi_data</structfield> <literal>OUT</literal>
      arguments are <literal>NULL</literal> for all rows returned).
      Obviously, this optimization is only feasible with queries where
      block data isn't truly required.
     </para>
     <para>
      The function raises an error if
      <replaceable>start_lsn</replaceable> is not available.
     </para>
    </listitem>
   </varlistentry>

    <varlistentry id="pgwalinspect-funcs-pg-get-wal-stats">
    <term>
     <function>
      pg_get_wal_stats(start_lsn pg_lsn, end_lsn pg_lsn, per_record boolean DEFAULT false)
      returns setof record
     </function>
    </term>

    <listitem>
     <para>
      Gets statistics of all the valid WAL records between
      <replaceable>start_lsn</replaceable> and
      <replaceable>end_lsn</replaceable>. By default, it returns one row per
      <replaceable>resource_manager</replaceable> type. When
      <replaceable>per_record</replaceable> is set to <literal>true</literal>,
      it returns one row per <replaceable>record_type</replaceable>.
      For example:
<screen>
postgres=# SELECT * FROM pg_get_wal_stats('0/1E847D00', '0/1E84F500')
           WHERE count > 0 AND
                 "resource_manager/record_type" = 'Transaction'
           LIMIT 1;
-[ RECORD 1 ]----------------+-------------------
resource_manager/record_type | Transaction
count                        | 2
count_percentage             | 8
record_size                  | 875
record_size_percentage       | 41.23468426013195
fpi_size                     | 0
fpi_size_percentage          | 0
combined_size                | 875
combined_size_percentage     | 2.8634072910530795
</screen>
     </para>
     <para>
      The function raises an error if
      <replaceable>start_lsn</replaceable> is not available.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
 </sect2>

 <sect2 id="pgwalinspect-author">
  <title>Author</title>

  <para>
   Bharath Rupireddy <email>bharath.rupireddyforpostgres@gmail.com</email>
  </para>
 </sect2>

</sect1>

Title: PostgreSQL WAL Inspection Functions and Parameters
Summary
This section describes various PostgreSQL WAL (Write-Ahead Logging) inspection functions and their parameters. It explains the relfilenode, relforknumber, and other fields that reference database objects. The pg_filenode_relation function is mentioned as a tool to determine which relation was modified during execution. The text also details an optimization technique for clients to avoid materializing block data by setting show_data to false, which can significantly improve function execution speed. Additionally, it introduces the pg_get_wal_stats function, which provides statistics on WAL records between specified LSN (Log Sequence Number) ranges, with an option to group results by resource manager type or record type. The section concludes by crediting the author, Bharath Rupireddy.