Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/pgvisibility.sgml`
3ba15798c4c36860f49250e09c8f6cfb42af26941318520d0000000100000be5
<!-- doc/src/sgml/pgvisibility.sgml -->

<sect1 id="pgvisibility" xreflabel="pg_visibility">
 <title>pg_visibility &mdash; visibility map information and utilities</title>

 <indexterm zone="pgvisibility">
  <primary>pg_visibility</primary>
 </indexterm>

 <para>
  The <filename>pg_visibility</filename> module provides a means for examining the
  visibility map (VM) and page-level visibility information of a table.
  It also provides functions to check the integrity of a visibility map and to
  force it to be rebuilt.
 </para>

 <para>
  Three different bits are used to store information about page-level
  visibility.  The all-visible bit in the visibility map indicates that every
  tuple in the corresponding page of the relation is visible to every current
  and future transaction.  The all-frozen bit in the visibility map indicates
  that every tuple in the page is frozen; that is, no future vacuum will need
  to modify the page until such time as a tuple is inserted, updated, deleted,
  or locked on that page.
  The page header's <literal>PD_ALL_VISIBLE</literal> bit has the
  same meaning as the all-visible bit in the visibility map, but is stored
  within the data page itself rather than in a separate data structure.
  These two bits will normally agree, but the page's all-visible bit can
  sometimes be set while the visibility map bit is clear after a crash
  recovery.  The reported values can also disagree because of a change that
  occurs after <literal>pg_visibility</literal> examines the visibility map and
  before it examines the data page.  Any event that causes data corruption
  can also cause these bits to disagree.
 </para>

 <para>
  Functions that display information about <literal>PD_ALL_VISIBLE</literal> bits
  are much more costly than those that only consult the visibility map,
  because they must read the relation's data blocks rather than only the
  (much smaller) visibility map.  Functions that check the relation's
  data blocks are similarly expensive.
 </para>

 <sect2 id="pgvisibility-funcs">
  <title>Functions</title>

  <variablelist>
   <varlistentry>
    <term><function>pg_visibility_map(relation regclass, blkno bigint, all_visible OUT boolean, all_frozen OUT boolean) returns record</function></term>
    <listitem>
     <para>
      Returns the all-visible and all-frozen bits in the visibility map for
      the given block of the given relation.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><function>pg_visibility(relation regclass, blkno bigint, all_visible OUT boolean, all_frozen OUT boolean, pd_all_visible OUT boolean) returns record</function></term>
    <listitem>
     <para>
      Returns the all-visible and all-frozen bits in the visibility map for
      the given block of the given relation, plus the
      <literal>PD_ALL_VISIBLE</literal> bit of that block.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><function>pg_visibility_map(relation regclass, blkno OUT bigint, all_visible OUT boolean,

Title: pg_visibility Module: Visibility Map Information and Functions
Summary
The pg_visibility module provides functions to examine and manage visibility maps and page-level visibility information in PostgreSQL tables. It includes functions to check visibility map integrity and force rebuilding. The module uses three bits to store visibility information: all-visible and all-frozen bits in the visibility map, and the PD_ALL_VISIBLE bit in page headers. The document describes these bits and their meanings, as well as the relative performance costs of different visibility-related functions. It also lists and explains several functions provided by the module for querying visibility information.