Home Explore Blog CI



postgresql

9th chunk of `doc/src/sgml/pageinspect.sgml`
86ea266e5527d2a853c9d9b38ef8ec5ea8b7ebc92ad192750000000100000fa9
 example:
<screen>
test=# SELECT * FROM gin_metapage_info(get_raw_page('gin_index', 0));
-[ RECORD 1 ]----+-----------
pending_head     | 4294967295
pending_tail     | 4294967295
tail_free_size   | 0
n_pending_pages  | 0
n_pending_tuples | 0
n_total_pages    | 7
n_entry_pages    | 6
n_data_pages     | 0
n_entries        | 693
version          | 2
</screen>
     </para>
    </listitem>
   </varlistentry>

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

    <listitem>
     <para>
      <function>gin_page_opaque_info</function> returns information about
      a <acronym>GIN</acronym> index opaque area, like the page type.
      For example:
<screen>
test=# SELECT * FROM gin_page_opaque_info(get_raw_page('gin_index', 2));
 rightlink | maxoff |         flags
-----------+--------+------------------------
         5 |      0 | {data,leaf,compressed}
(1 row)
</screen>
     </para>
    </listitem>
   </varlistentry>

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

    <listitem>
     <para>
      <function>gin_leafpage_items</function> returns information about
      the data stored in a compressed <acronym>GIN</acronym> leaf page.  For example:
<screen>
test=# SELECT first_tid, nbytes, tids[0:5] AS some_tids
        FROM gin_leafpage_items(get_raw_page('gin_test_idx', 2));
 first_tid | nbytes |                        some_tids
-----------+--------+----------------------------------------------------------
 (8,41)    |    244 | {"(8,41)","(8,43)","(8,44)","(8,45)","(8,46)"}
 (10,45)   |    248 | {"(10,45)","(10,46)","(10,47)","(10,48)","(10,49)"}
 (12,52)   |    248 | {"(12,52)","(12,53)","(12,54)","(12,55)","(12,56)"}
 (14,59)   |    320 | {"(14,59)","(14,60)","(14,61)","(14,62)","(14,63)"}
 (167,16)  |    376 | {"(167,16)","(167,17)","(167,18)","(167,19)","(167,20)"}
 (170,30)  |    376 | {"(170,30)","(170,31)","(170,32)","(170,33)","(170,34)"}
 (173,44)  |    197 | {"(173,44)","(173,45)","(173,46)","(173,47)","(173,48)"}
(7 rows)
</screen>
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </sect2>

 <sect2 id="pageinspect-gist-funcs">
  <title>GiST Functions</title>

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

    <listitem>
     <para>
      <function>gist_page_opaque_info</function> returns information from
      a <acronym>GiST</acronym> index page's opaque area, such as the NSN,
      rightlink and page type.
      For example:
<screen>
test=# SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2));
 lsn | nsn | rightlink | flags
-----+-----+-----------+--------
 0/1 | 0/0 |         1 | {leaf}
(1 row)
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>gist_page_items(page bytea, index_oid regclass) returns setof record</function>
     <indexterm>
      <primary>gist_page_items</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>gist_page_items</function> returns information about
      the data stored in a page of a <acronym>GiST</acronym> index.  For example:
<screen>
test=# SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gist_idx');
 itemoffset |   ctid    | itemlen | dead |             keys
------------+-----------+---------+------+-------------------------------
          1 | (1,65535) |      40 | f    | (p)=("(185,185),(1,1)")
          2 | (2,65535) |      40 | f    | (p)=("(370,370),(186,186)")
          3 | (3,65535) |      40 | f    | (p)=("(555,555),(371,371)")
          4 | (4,65535) |      40 | f    | (p)=("(740,740),(556,556)")

Title: GiST Functions
Summary
The pageinspect module provides functions to inspect and analyze GiST index pages, including gist_page_opaque_info and gist_page_items, which return information about opaque areas and page data, such as page type, NSN, rightlink, and item details, allowing for a deeper understanding of GiST index structure and operation.