Home Explore Blog CI



postgresql

12th chunk of `doc/src/sgml/pageinspect.sgml`
93b8d9fef6397144f110dfa4b0dfc7aebf3a59e9dcdc90a70000000100000ca5

      <function>hash_page_stats</function> returns information about
      a bucket or overflow page of a <acronym>HASH</acronym> index.
      For example:
<screen>
test=# SELECT * FROM hash_page_stats(get_raw_page('con_hash_index', 1));
-[ RECORD 1 ]---+-----------
live_items      | 407
dead_items      | 0
page_size       | 8192
free_size       | 8
hasho_prevblkno | 4096
hasho_nextblkno | 8474
hasho_bucket    | 0
hasho_flag      | 66
hasho_page_id   | 65408
</screen>
     </para>
    </listitem>
   </varlistentry>

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

    <listitem>
     <para>
      <function>hash_page_items</function> returns information about
      the data stored in a bucket or overflow page of a <acronym>HASH</acronym>
      index page.  For example:
<screen>
test=# SELECT * FROM hash_page_items(get_raw_page('con_hash_index', 1)) LIMIT 5;
 itemoffset |   ctid    |    data
------------+-----------+------------
          1 | (899,77)  | 1053474816
          2 | (897,29)  | 1053474816
          3 | (894,207) | 1053474816
          4 | (892,159) | 1053474816
          5 | (890,111) | 1053474816
</screen>
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term>
     <function>hash_bitmap_info(index oid, blkno bigint) returns record</function>
     <indexterm>
      <primary>hash_bitmap_info</primary>
     </indexterm>
    </term>

    <listitem>
     <para>
      <function>hash_bitmap_info</function> shows the status of a bit
      in the bitmap page for a particular overflow page of <acronym>HASH</acronym>
      index. For example:
<screen>
test=# SELECT * FROM hash_bitmap_info('con_hash_index', 2052);
 bitmapblkno | bitmapbit | bitstatus
-------------+-----------+-----------
          65 |         3 | t
</screen>
     </para>
    </listitem>
   </varlistentry>

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

    <listitem>
     <para>
      <function>hash_metapage_info</function> returns information stored
      in the meta page of a <acronym>HASH</acronym> index.  For example:
<screen>
test=# SELECT magic, version, ntuples, ffactor, bsize, bmsize, bmshift,
test-#     maxbucket, highmask, lowmask, ovflpoint, firstfree, nmaps, procid,
test-#     regexp_replace(spares::text, '(,0)*}', '}') as spares,
test-#     regexp_replace(mapp::text, '(,0)*}', '}') as mapp
test-# FROM hash_metapage_info(get_raw_page('con_hash_index', 0));
-[ RECORD 1 ]-------------------------------------------------&zwsp;------------------------------
magic     | 105121344
version   | 4
ntuples   | 500500
ffactor   | 40
bsize     | 8152
bmsize    | 4096
bmshift   | 15
maxbucket | 12512
highmask  | 16383
lowmask   | 8191
ovflpoint | 28
firstfree | 1204
nmaps     | 1
procid    | 450
spares    | {0,0,0,0,0,0,1,1,1,1,1,1,1,1,3,4,4,4,45,55,58,59,&zwsp;508,567,628,704,1193,1202,1204}
mapp      | {65}
</screen>
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </sect2>

</sect1>

Title: Hash Index Page Inspection Functions
Summary
The pageinspect module provides additional functions to analyze and inspect HASH index pages, including hash_page_items, hash_bitmap_info, and hash_metapage_info, which return information about data stored in bucket or overflow pages, bitmap page status, and meta page information, allowing for a detailed examination of HASH index structure and operation.