Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/pageinspect.sgml`
603fb62ece95234eb5344c6705b32005f28db75dfc3d4fdf0000000100000fa4
 column for combined flags. For example:
<screen>
test=# SELECT t_ctid, raw_flags, combined_flags
         FROM heap_page_items(get_raw_page('pg_class', 0)),
           LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2)
         WHERE t_infomask IS NOT NULL OR t_infomask2 IS NOT NULL;
</screen>
      This function should be called with the same arguments as the return
      attributes of <function>heap_page_items</function>.
     </para>
     <para>
      Combined flags are displayed for source-level macros that take into
      account the value of more than one raw bit, such as
      <literal>HEAP_XMIN_FROZEN</literal>.
     </para>
     <para>
      See <filename>src/include/access/htup_details.h</filename> for
      explanations of the flag names returned.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </sect2>

 <sect2 id="pageinspect-b-tree-funcs">
  <title>B-Tree Functions</title>

  <variablelist>
   <varlistentry>
    <term>
     <function>bt_metap(relname text) returns record</function>
     <indexterm>
      <primary>bt_metap</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>bt_metap</function> returns information about a B-tree
      index's metapage.  For example:
<screen>
test=# SELECT * FROM bt_metap('pg_cast_oid_index');
-[ RECORD 1 ]-------------+-------
magic                     | 340322
version                   | 4
root                      | 1
level                     | 0
fastroot                  | 1
fastlevel                 | 0
last_cleanup_num_delpages | 0
last_cleanup_num_tuples   | 230
allequalimage             | f
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>bt_page_stats(relname text, blkno bigint) returns record</function>
     <indexterm>
      <primary>bt_page_stats</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>bt_page_stats</function> returns summary information about
      a data page of a B-tree index.  For example:
<screen>
test=# SELECT * FROM bt_page_stats('pg_cast_oid_index', 1);
-[ RECORD 1 ]-+-----
blkno         | 1
type          | l
live_items    | 224
dead_items    | 0
avg_item_size | 16
page_size     | 8192
free_size     | 3668
btpo_prev     | 0
btpo_next     | 0
btpo_level    | 0
btpo_flags    | 3
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>bt_multi_page_stats(relname text, blkno bigint, blk_count bigint) returns setof record</function>
     <indexterm>
      <primary>bt_multi_page_stats</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>bt_multi_page_stats</function> returns the same information
      as <function>bt_page_stats</function>, but does so for each page of the
      range of pages beginning at <parameter>blkno</parameter> and extending
      for <parameter>blk_count</parameter> pages.
      If <parameter>blk_count</parameter> is negative, all pages
      from <parameter>blkno</parameter> to the end of the index are reported
      on.  For example:
<screen>
test=# SELECT * FROM bt_multi_page_stats('pg_proc_oid_index', 5, 2);
-[ RECORD 1 ]-+-----
blkno         | 5
type          | l
live_items    | 367
dead_items    | 0
avg_item_size | 16
page_size     | 8192
free_size     | 808
btpo_prev     | 4
btpo_next     | 6
btpo_level    | 0
btpo_flags    | 1
-[ RECORD 2 ]-+-----
blkno         | 6
type          | l
live_items    | 367
dead_items    | 0
avg_item_size | 16
page_size     | 8192
free_size     | 808
btpo_prev     | 5
btpo_next     | 7
btpo_level    | 0
btpo_flags    | 1
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>bt_page_items(relname text, blkno bigint) returns setof record</function>
     <indexterm>
      <primary>bt_page_items</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>bt_page_items</function> returns detailed information about

Title: B-Tree Inspection Functions in PostgreSQL
Summary
The pageinspect module provides functions for inspecting B-tree indexes, including bt_metap, bt_page_stats, bt_multi_page_stats, and bt_page_items, which allow superusers to examine metapage information, page statistics, and item details for specific indexes and pages.