Home Explore Blog CI



postgresql

7th chunk of `doc/src/sgml/pageinspect.sgml`
93ed0e7ddf4265f8e7623204cc811e2ae7f0b18f430b6da30000000100000fa0
 <function>get_raw_page</function> should be passed as argument.  So
      the last example could also be rewritten like this:
<screen>
test=# SELECT itemoffset, ctid, itemlen, nulls, vars, data, dead, htid, tids[0:2] AS some_tids
        FROM bt_page_items(get_raw_page('tenk2_hundred', 5));
 itemoffset |   ctid    | itemlen | nulls | vars |          data           | dead |  htid  |      some_tids
------------+-----------+---------+-------+------+-------------------------+------+--------+---------------------
          1 | (16,1)    |      16 | f     | f    | 30 00 00 00 00 00 00 00 |      |        |
          2 | (16,8292) |     616 | f     | f    | 24 00 00 00 00 00 00 00 | f    | (1,6)  | {"(1,6)","(10,22)"}
          3 | (16,8292) |     616 | f     | f    | 25 00 00 00 00 00 00 00 | f    | (1,18) | {"(1,18)","(4,22)"}
          4 | (16,8292) |     616 | f     | f    | 26 00 00 00 00 00 00 00 | f    | (4,18) | {"(4,18)","(6,17)"}
          5 | (16,8292) |     616 | f     | f    | 27 00 00 00 00 00 00 00 | f    | (1,2)  | {"(1,2)","(1,19)"}
          6 | (16,8292) |     616 | f     | f    | 28 00 00 00 00 00 00 00 | f    | (2,24) | {"(2,24)","(4,11)"}
          7 | (16,8292) |     616 | f     | f    | 29 00 00 00 00 00 00 00 | f    | (2,17) | {"(2,17)","(11,2)"}
          8 | (16,8292) |     616 | f     | f    | 2a 00 00 00 00 00 00 00 | f    | (0,25) | {"(0,25)","(3,20)"}
          9 | (16,8292) |     616 | f     | f    | 2b 00 00 00 00 00 00 00 | f    | (0,10) | {"(0,10)","(0,14)"}
         10 | (16,8292) |     616 | f     | f    | 2c 00 00 00 00 00 00 00 | f    | (1,3)  | {"(1,3)","(3,9)"}
         11 | (16,8292) |     616 | f     | f    | 2d 00 00 00 00 00 00 00 | f    | (6,28) | {"(6,28)","(11,1)"}
         12 | (16,8292) |     616 | f     | f    | 2e 00 00 00 00 00 00 00 | f    | (0,27) | {"(0,27)","(1,13)"}
         13 | (16,8292) |     616 | f     | f    | 2f 00 00 00 00 00 00 00 | f    | (4,17) | {"(4,17)","(4,21)"}
(13 rows)
</screen>
      All the other details are the same as explained in the previous item.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </sect2>

 <sect2 id="pageinspect-brin-funcs">
  <title>BRIN Functions</title>

  <variablelist>
   <varlistentry>
    <term>
     <function>brin_page_type(page bytea) returns text</function>
     <indexterm>
      <primary>brin_page_type</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>brin_page_type</function> returns the page type of the given
      <acronym>BRIN</acronym> index page, or throws an error if the page is
      not a valid <acronym>BRIN</acronym> page.  For example:
<screen>
test=# SELECT brin_page_type(get_raw_page('brinidx', 0));
 brin_page_type
----------------
 meta
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>brin_metapage_info(page bytea) returns record</function>
     <indexterm>
      <primary>brin_metapage_info</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>brin_metapage_info</function> returns assorted information
      about a <acronym>BRIN</acronym> index metapage.  For example:
<screen>
test=# SELECT * FROM brin_metapage_info(get_raw_page('brinidx', 0));
   magic    | version | pagesperrange | lastrevmappage
------------+---------+---------------+----------------
 0xA8109CFA |       1 |             4 |              2
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>brin_revmap_data(page bytea) returns setof tid</function>
     <indexterm>
      <primary>brin_revmap_data</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>brin_revmap_data</function> returns the list of tuple
      identifiers in a <acronym>BRIN</acronym> index range map page.
      For example:
<screen>
test=# SELECT * FROM brin_revmap_data(get_raw_page('brinidx', 2)) LIMIT 5;
  pages
---------
 (6,137)
 (6,138)
 (6,139)
 (6,140)
 (6,141)

Title: Page Inspection Functions
Summary
The pageinspect module provides functions to inspect and analyze B-tree and BRIN index pages, including bt_page_items, brin_page_type, brin_metapage_info, and brin_revmap_data, which return detailed information about page types, metapage information, and tuple identifiers, allowing for a deeper understanding of index structure and operation.