1<!-- doc/src/sgml/pageinspect.sgml --> 2 3<sect1 id="pageinspect" xreflabel="pageinspect"> 4 <title>pageinspect</title> 5 6 <indexterm zone="pageinspect"> 7 <primary>pageinspect</primary> 8 </indexterm> 9 10 <para> 11 The <filename>pageinspect</filename> module provides functions that allow you to 12 inspect the contents of database pages at a low level, which is useful for 13 debugging purposes. All of these functions may be used only by superusers. 14 </para> 15 16 <sect2> 17 <title>General Functions</title> 18 19 <variablelist> 20 <varlistentry> 21 <term> 22 <function>get_raw_page(relname text, fork text, blkno int) returns bytea</function> 23 <indexterm> 24 <primary>get_raw_page</primary> 25 </indexterm> 26 </term> 27 28 <listitem> 29 <para> 30 <function>get_raw_page</function> reads the specified block of the named 31 relation and returns a copy as a <type>bytea</type> value. This allows a 32 single time-consistent copy of the block to be obtained. 33 <replaceable>fork</replaceable> should be <literal>'main'</literal> for 34 the main data fork, <literal>'fsm'</literal> for the free space map, 35 <literal>'vm'</literal> for the visibility map, or <literal>'init'</literal> 36 for the initialization fork. 37 </para> 38 </listitem> 39 </varlistentry> 40 41 <varlistentry> 42 <term> 43 <function>get_raw_page(relname text, blkno int) returns bytea</function> 44 </term> 45 46 <listitem> 47 <para> 48 A shorthand version of <function>get_raw_page</function>, for reading 49 from the main fork. Equivalent to 50 <literal>get_raw_page(relname, 'main', blkno)</literal> 51 </para> 52 </listitem> 53 </varlistentry> 54 55 <varlistentry> 56 <term> 57 <function>page_header(page bytea) returns record</function> 58 <indexterm> 59 <primary>page_header</primary> 60 </indexterm> 61 </term> 62 63 <listitem> 64 <para> 65 <function>page_header</function> shows fields that are common to all 66 <productname>PostgreSQL</productname> heap and index pages. 67 </para> 68 69 <para> 70 A page image obtained with <function>get_raw_page</function> should be 71 passed as argument. For example: 72<screen> 73test=# SELECT * FROM page_header(get_raw_page('pg_class', 0)); 74 lsn | checksum | flags | lower | upper | special | pagesize | version | prune_xid 75-----------+----------+--------+-------+-------+---------+----------+---------+----------- 76 0/24A1B50 | 0 | 1 | 232 | 368 | 8192 | 8192 | 4 | 0 77</screen> 78 The returned columns correspond to the fields in the 79 <structname>PageHeaderData</structname> struct. 80 See <filename>src/include/storage/bufpage.h</filename> for details. 81 </para> 82 83 <para> 84 The <structfield>checksum</structfield> field is the checksum stored in 85 the page, which might be incorrect if the page is somehow corrupted. If 86 data checksums are not enabled for this instance, then the value stored 87 is meaningless. 88 </para> 89 </listitem> 90 </varlistentry> 91 92 <varlistentry> 93 <term> 94 <function>page_checksum(page bytea, blkno int4) returns smallint</function> 95 <indexterm> 96 <primary>page_checksum</primary> 97 </indexterm> 98 </term> 99 100 <listitem> 101 <para> 102 <function>page_checksum</function> computes the checksum for the page, as if 103 it was located at the given block. 104 </para> 105 106 <para> 107 A page image obtained with <function>get_raw_page</function> should be 108 passed as argument. For example: 109<screen> 110test=# SELECT page_checksum(get_raw_page('pg_class', 0), 0); 111 page_checksum 112--------------- 113 13443 114</screen> 115 Note that the checksum depends on the block number, so matching block 116 numbers should be passed (except when doing esoteric debugging). 117 </para> 118 119 <para> 120 The checksum computed with this function can be compared with 121 the <structfield>checksum</structfield> result field of the 122 function <function>page_header</function>. If data checksums are 123 enabled for this instance, then the two values should be equal. 124 </para> 125 </listitem> 126 </varlistentry> 127 128 <varlistentry> 129 <term> 130 <function>fsm_page_contents(page bytea) returns text</function> 131 <indexterm> 132 <primary>fsm_page_contents</primary> 133 </indexterm> 134 </term> 135 136 <listitem> 137 <para> 138 <function>fsm_page_contents</function> shows the internal node structure 139 of a FSM page. For example: 140<screen> 141test=# SELECT fsm_page_contents(get_raw_page('pg_class', 'fsm', 0)); 142</screen> 143 The output is a multiline string, with one line per node in the binary 144 tree within the page. Only those nodes that are not zero are printed. 145 The so-called "next" pointer, which points to the next slot to be 146 returned from the page, is also printed. 147 </para> 148 <para> 149 See <filename>src/backend/storage/freespace/README</filename> for more 150 information on the structure of an FSM page. 151 </para> 152 </listitem> 153 </varlistentry> 154 </variablelist> 155 </sect2> 156 157 <sect2> 158 <title>Heap Functions</title> 159 160 <variablelist> 161 <varlistentry> 162 <term> 163 <function>heap_page_items(page bytea) returns setof record</function> 164 <indexterm> 165 <primary>heap_page_items</primary> 166 </indexterm> 167 </term> 168 169 <listitem> 170 <para> 171 <function>heap_page_items</function> shows all line pointers on a heap 172 page. For those line pointers that are in use, tuple headers as well 173 as tuple raw data are also shown. All tuples are shown, whether or not 174 the tuples were visible to an MVCC snapshot at the time the raw page 175 was copied. 176 </para> 177 <para> 178 A heap page image obtained with <function>get_raw_page</function> should 179 be passed as argument. For example: 180<screen> 181test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0)); 182</screen> 183 See <filename>src/include/storage/itemid.h</filename> and 184 <filename>src/include/access/htup_details.h</filename> for explanations of the fields 185 returned. 186 </para> 187 <para> 188 The <function>heap_tuple_infomask_flags</function> function can be 189 used to unpack the flag bits of <structfield>t_infomask</structfield> 190 and <structfield>t_infomask2</structfield> for heap tuples. 191 </para> 192 </listitem> 193 </varlistentry> 194 195 <varlistentry> 196 <term> 197 <function>tuple_data_split(rel_oid oid, t_data bytea, t_infomask integer, t_infomask2 integer, t_bits text [, do_detoast bool]) returns bytea[]</function> 198 <indexterm> 199 <primary>tuple_data_split</primary> 200 </indexterm> 201 </term> 202 <listitem> 203 <para> 204 <function>tuple_data_split</function> splits tuple data into attributes 205 in the same way as backend internals. 206<screen> 207test=# SELECT tuple_data_split('pg_class'::regclass, t_data, t_infomask, t_infomask2, t_bits) FROM heap_page_items(get_raw_page('pg_class', 0)); 208</screen> 209 This function should be called with the same arguments as the return 210 attributes of <function>heap_page_items</function>. 211 </para> 212 <para> 213 If <parameter>do_detoast</parameter> is <literal>true</literal>, 214 attributes will be detoasted as needed. Default value is 215 <literal>false</literal>. 216 </para> 217 </listitem> 218 </varlistentry> 219 220 <varlistentry> 221 <term> 222 <function>heap_page_item_attrs(page bytea, rel_oid regclass [, do_detoast bool]) returns setof record</function> 223 <indexterm> 224 <primary>heap_page_item_attrs</primary> 225 </indexterm> 226 </term> 227 <listitem> 228 <para> 229 <function>heap_page_item_attrs</function> is equivalent to 230 <function>heap_page_items</function> except that it returns 231 tuple raw data as an array of attributes that can optionally 232 be detoasted by <parameter>do_detoast</parameter> which is 233 <literal>false</literal> by default. 234 </para> 235 <para> 236 A heap page image obtained with <function>get_raw_page</function> should 237 be passed as argument. For example: 238<screen> 239test=# SELECT * FROM heap_page_item_attrs(get_raw_page('pg_class', 0), 'pg_class'::regclass); 240</screen> 241 </para> 242 </listitem> 243 </varlistentry> 244 245 <varlistentry> 246 <term> 247 <function>heap_tuple_infomask_flags(t_infomask integer, t_infomask2 integer) returns record</function> 248 <indexterm> 249 <primary>heap_tuple_infomask_flags</primary> 250 </indexterm> 251 </term> 252 <listitem> 253 <para> 254 <function>heap_tuple_infomask_flags</function> decodes the 255 <structfield>t_infomask</structfield> and 256 <structfield>t_infomask2</structfield> returned by 257 <function>heap_page_items</function> into a human-readable 258 set of arrays made of flag names, with one column for all 259 the flags and one column for combined flags. For example: 260<screen> 261test=# SELECT t_ctid, raw_flags, combined_flags 262 FROM heap_page_items(get_raw_page('pg_class', 0)), 263 LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2) 264 WHERE t_infomask IS NOT NULL OR t_infomask2 IS NOT NULL; 265</screen> 266 This function should be called with the same arguments as the return 267 attributes of <function>heap_page_items</function>. 268 </para> 269 <para> 270 Combined flags are displayed for source-level macros that take into 271 account the value of more than one raw bit, such as 272 <literal>HEAP_XMIN_FROZEN</literal>. 273 </para> 274 <para> 275 See <filename>src/include/access/htup_details.h</filename> for 276 explanations of the flag names returned. 277 </para> 278 </listitem> 279 </varlistentry> 280 </variablelist> 281 </sect2> 282 283 <sect2> 284 <title>B-Tree Functions</title> 285 286 <variablelist> 287 <varlistentry> 288 <term> 289 <function>bt_metap(relname text) returns record</function> 290 <indexterm> 291 <primary>bt_metap</primary> 292 </indexterm> 293 </term> 294 295 <listitem> 296 <para> 297 <function>bt_metap</function> returns information about a B-tree 298 index's metapage. For example: 299<screen> 300test=# SELECT * FROM bt_metap('pg_cast_oid_index'); 301-[ RECORD 1 ]-----------+------- 302magic | 340322 303version | 4 304root | 1 305level | 0 306fastroot | 1 307fastlevel | 0 308oldest_xact | 582 309last_cleanup_num_tuples | 1000 310allequalimage | f 311</screen> 312 </para> 313 </listitem> 314 </varlistentry> 315 316 <varlistentry> 317 <term> 318 <function>bt_page_stats(relname text, blkno int) returns record</function> 319 <indexterm> 320 <primary>bt_page_stats</primary> 321 </indexterm> 322 </term> 323 324 <listitem> 325 <para> 326 <function>bt_page_stats</function> returns summary information about 327 single pages of B-tree indexes. For example: 328<screen> 329test=# SELECT * FROM bt_page_stats('pg_cast_oid_index', 1); 330-[ RECORD 1 ]-+----- 331blkno | 1 332type | l 333live_items | 224 334dead_items | 0 335avg_item_size | 16 336page_size | 8192 337free_size | 3668 338btpo_prev | 0 339btpo_next | 0 340btpo | 0 341btpo_flags | 3 342</screen> 343 </para> 344 </listitem> 345 </varlistentry> 346 347 <varlistentry> 348 <term> 349 <function>bt_page_items(relname text, blkno int) returns setof record</function> 350 <indexterm> 351 <primary>bt_page_items</primary> 352 </indexterm> 353 </term> 354 355 <listitem> 356 <para> 357 <function>bt_page_items</function> returns detailed information about 358 all of the items on a B-tree index page. For example: 359<screen> 360test=# SELECT itemoffset, ctid, itemlen, nulls, vars, data, dead, htid, tids[0:2] AS some_tids 361 FROM bt_page_items('tenk2_hundred', 5); 362 itemoffset | ctid | itemlen | nulls | vars | data | dead | htid | some_tids 363------------+-----------+---------+-------+------+-------------------------+------+--------+--------------------- 364 1 | (16,1) | 16 | f | f | 30 00 00 00 00 00 00 00 | | | 365 2 | (16,8292) | 616 | f | f | 24 00 00 00 00 00 00 00 | f | (1,6) | {"(1,6)","(10,22)"} 366 3 | (16,8292) | 616 | f | f | 25 00 00 00 00 00 00 00 | f | (1,18) | {"(1,18)","(4,22)"} 367 4 | (16,8292) | 616 | f | f | 26 00 00 00 00 00 00 00 | f | (4,18) | {"(4,18)","(6,17)"} 368 5 | (16,8292) | 616 | f | f | 27 00 00 00 00 00 00 00 | f | (1,2) | {"(1,2)","(1,19)"} 369 6 | (16,8292) | 616 | f | f | 28 00 00 00 00 00 00 00 | f | (2,24) | {"(2,24)","(4,11)"} 370 7 | (16,8292) | 616 | f | f | 29 00 00 00 00 00 00 00 | f | (2,17) | {"(2,17)","(11,2)"} 371 8 | (16,8292) | 616 | f | f | 2a 00 00 00 00 00 00 00 | f | (0,25) | {"(0,25)","(3,20)"} 372 9 | (16,8292) | 616 | f | f | 2b 00 00 00 00 00 00 00 | f | (0,10) | {"(0,10)","(0,14)"} 373 10 | (16,8292) | 616 | f | f | 2c 00 00 00 00 00 00 00 | f | (1,3) | {"(1,3)","(3,9)"} 374 11 | (16,8292) | 616 | f | f | 2d 00 00 00 00 00 00 00 | f | (6,28) | {"(6,28)","(11,1)"} 375 12 | (16,8292) | 616 | f | f | 2e 00 00 00 00 00 00 00 | f | (0,27) | {"(0,27)","(1,13)"} 376 13 | (16,8292) | 616 | f | f | 2f 00 00 00 00 00 00 00 | f | (4,17) | {"(4,17)","(4,21)"} 377(13 rows) 378</screen> 379 This is a B-tree leaf page. All tuples that point to the table 380 happen to be posting list tuples (all of which store a total of 381 100 6 byte TIDs). There is also a <quote>high key</quote> tuple 382 at <literal>itemoffset</literal> number 1. 383 <structfield>ctid</structfield> is used to store encoded 384 information about each tuple in this example, though leaf page 385 tuples often store a heap TID directly in the 386 <structfield>ctid</structfield> field instead. 387 <structfield>tids</structfield> is the list of TIDs stored as a 388 posting list. 389 </para> 390 <para> 391 In an internal page (not shown), the block number part of 392 <structfield>ctid</structfield> is a <quote>downlink</quote>, 393 which is a block number of another page in the index itself. 394 The offset part (the second number) of 395 <structfield>ctid</structfield> stores encoded information about 396 the tuple, such as the number of columns present (suffix 397 truncation may have removed unneeded suffix columns). Truncated 398 columns are treated as having the value <quote>minus 399 infinity</quote>. 400 </para> 401 <para> 402 <structfield>htid</structfield> shows a heap TID for the tuple, 403 regardless of the underlying tuple representation. This value 404 may match <structfield>ctid</structfield>, or may be decoded 405 from the alternative representations used by posting list tuples 406 and tuples from internal pages. Tuples in internal pages 407 usually have the implementation level heap TID column truncated 408 away, which is represented as a NULL 409 <structfield>htid</structfield> value. 410 </para> 411 <para> 412 Note that the first item on any non-rightmost page (any page with 413 a non-zero value in the <structfield>btpo_next</structfield> field) is the 414 page's <quote>high key</quote>, meaning its <structfield>data</structfield> 415 serves as an upper bound on all items appearing on the page, while 416 its <structfield>ctid</structfield> field does not point to 417 another block. Also, on internal pages, the first real data 418 item (the first item that is not a high key) reliably has every 419 column truncated away, leaving no actual value in its 420 <structfield>data</structfield> field. Such an item does have a 421 valid downlink in its <structfield>ctid</structfield> field, 422 however. 423 </para> 424 <para> 425 For more details about the structure of B-tree indexes, see 426 <xref linkend="btree-structure"/>. For more details about 427 deduplication and posting lists, see <xref 428 linkend="btree-deduplication"/>. 429 </para> 430 </listitem> 431 </varlistentry> 432 433 <varlistentry> 434 <term> 435 <function>bt_page_items(page bytea) returns setof record</function> 436 <indexterm> 437 <primary>bt_page_items</primary> 438 </indexterm> 439 </term> 440 441 <listitem> 442 <para> 443 It is also possible to pass a page to <function>bt_page_items</function> 444 as a <type>bytea</type> value. A page image obtained 445 with <function>get_raw_page</function> should be passed as argument. So 446 the last example could also be rewritten like this: 447<screen> 448test=# SELECT itemoffset, ctid, itemlen, nulls, vars, data, dead, htid, tids[0:2] AS some_tids 449 FROM bt_page_items(get_raw_page('tenk2_hundred', 5)); 450 itemoffset | ctid | itemlen | nulls | vars | data | dead | htid | some_tids 451------------+-----------+---------+-------+------+-------------------------+------+--------+--------------------- 452 1 | (16,1) | 16 | f | f | 30 00 00 00 00 00 00 00 | | | 453 2 | (16,8292) | 616 | f | f | 24 00 00 00 00 00 00 00 | f | (1,6) | {"(1,6)","(10,22)"} 454 3 | (16,8292) | 616 | f | f | 25 00 00 00 00 00 00 00 | f | (1,18) | {"(1,18)","(4,22)"} 455 4 | (16,8292) | 616 | f | f | 26 00 00 00 00 00 00 00 | f | (4,18) | {"(4,18)","(6,17)"} 456 5 | (16,8292) | 616 | f | f | 27 00 00 00 00 00 00 00 | f | (1,2) | {"(1,2)","(1,19)"} 457 6 | (16,8292) | 616 | f | f | 28 00 00 00 00 00 00 00 | f | (2,24) | {"(2,24)","(4,11)"} 458 7 | (16,8292) | 616 | f | f | 29 00 00 00 00 00 00 00 | f | (2,17) | {"(2,17)","(11,2)"} 459 8 | (16,8292) | 616 | f | f | 2a 00 00 00 00 00 00 00 | f | (0,25) | {"(0,25)","(3,20)"} 460 9 | (16,8292) | 616 | f | f | 2b 00 00 00 00 00 00 00 | f | (0,10) | {"(0,10)","(0,14)"} 461 10 | (16,8292) | 616 | f | f | 2c 00 00 00 00 00 00 00 | f | (1,3) | {"(1,3)","(3,9)"} 462 11 | (16,8292) | 616 | f | f | 2d 00 00 00 00 00 00 00 | f | (6,28) | {"(6,28)","(11,1)"} 463 12 | (16,8292) | 616 | f | f | 2e 00 00 00 00 00 00 00 | f | (0,27) | {"(0,27)","(1,13)"} 464 13 | (16,8292) | 616 | f | f | 2f 00 00 00 00 00 00 00 | f | (4,17) | {"(4,17)","(4,21)"} 465(13 rows) 466</screen> 467 All the other details are the same as explained in the previous item. 468 </para> 469 </listitem> 470 </varlistentry> 471 </variablelist> 472 </sect2> 473 474 <sect2> 475 <title>BRIN Functions</title> 476 477 <variablelist> 478 <varlistentry> 479 <term> 480 <function>brin_page_type(page bytea) returns text</function> 481 <indexterm> 482 <primary>brin_page_type</primary> 483 </indexterm> 484 </term> 485 486 <listitem> 487 <para> 488 <function>brin_page_type</function> returns the page type of the given 489 <acronym>BRIN</acronym> index page, or throws an error if the page is 490 not a valid <acronym>BRIN</acronym> page. For example: 491<screen> 492test=# SELECT brin_page_type(get_raw_page('brinidx', 0)); 493 brin_page_type 494---------------- 495 meta 496</screen> 497 </para> 498 </listitem> 499 </varlistentry> 500 501 <varlistentry> 502 <term> 503 <function>brin_metapage_info(page bytea) returns record</function> 504 <indexterm> 505 <primary>brin_metapage_info</primary> 506 </indexterm> 507 </term> 508 509 <listitem> 510 <para> 511 <function>brin_metapage_info</function> returns assorted information 512 about a <acronym>BRIN</acronym> index metapage. For example: 513<screen> 514test=# SELECT * FROM brin_metapage_info(get_raw_page('brinidx', 0)); 515 magic | version | pagesperrange | lastrevmappage 516------------+---------+---------------+---------------- 517 0xA8109CFA | 1 | 4 | 2 518</screen> 519 </para> 520 </listitem> 521 </varlistentry> 522 523 <varlistentry> 524 <term> 525 <function>brin_revmap_data(page bytea) returns setof tid</function> 526 <indexterm> 527 <primary>brin_revmap_data</primary> 528 </indexterm> 529 </term> 530 531 <listitem> 532 <para> 533 <function>brin_revmap_data</function> returns the list of tuple 534 identifiers in a <acronym>BRIN</acronym> index range map page. 535 For example: 536<screen> 537test=# SELECT * FROM brin_revmap_data(get_raw_page('brinidx', 2)) LIMIT 5; 538 pages 539--------- 540 (6,137) 541 (6,138) 542 (6,139) 543 (6,140) 544 (6,141) 545</screen> 546 </para> 547 </listitem> 548 </varlistentry> 549 550 <varlistentry> 551 <term> 552 <function>brin_page_items(page bytea, index oid) returns setof record</function> 553 <indexterm> 554 <primary>brin_page_items</primary> 555 </indexterm> 556 </term> 557 558 <listitem> 559 <para> 560 <function>brin_page_items</function> returns the data stored in the 561 <acronym>BRIN</acronym> data page. For example: 562<screen> 563test=# SELECT * FROM brin_page_items(get_raw_page('brinidx', 5), 564 'brinidx') 565 ORDER BY blknum, attnum LIMIT 6; 566 itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | value 567------------+--------+--------+----------+----------+-------------+-------------- 568 137 | 0 | 1 | t | f | f | 569 137 | 0 | 2 | f | f | f | {1 .. 88} 570 138 | 4 | 1 | t | f | f | 571 138 | 4 | 2 | f | f | f | {89 .. 176} 572 139 | 8 | 1 | t | f | f | 573 139 | 8 | 2 | f | f | f | {177 .. 264} 574</screen> 575 The returned columns correspond to the fields in the 576 <structname>BrinMemTuple</structname> and <structname>BrinValues</structname> structs. 577 See <filename>src/include/access/brin_tuple.h</filename> for details. 578 </para> 579 </listitem> 580 </varlistentry> 581 </variablelist> 582 </sect2> 583 584 <sect2> 585 <title>GIN Functions</title> 586 587 <variablelist> 588 <varlistentry> 589 <term> 590 <function>gin_metapage_info(page bytea) returns record</function> 591 <indexterm> 592 <primary>gin_metapage_info</primary> 593 </indexterm> 594 </term> 595 596 <listitem> 597 <para> 598 <function>gin_metapage_info</function> returns information about 599 a <acronym>GIN</acronym> index metapage. For example: 600<screen> 601test=# SELECT * FROM gin_metapage_info(get_raw_page('gin_index', 0)); 602-[ RECORD 1 ]----+----------- 603pending_head | 4294967295 604pending_tail | 4294967295 605tail_free_size | 0 606n_pending_pages | 0 607n_pending_tuples | 0 608n_total_pages | 7 609n_entry_pages | 6 610n_data_pages | 0 611n_entries | 693 612version | 2 613</screen> 614 </para> 615 </listitem> 616 </varlistentry> 617 618 <varlistentry> 619 <term> 620 <function>gin_page_opaque_info(page bytea) returns record</function> 621 <indexterm> 622 <primary>gin_page_opaque_info</primary> 623 </indexterm> 624 </term> 625 626 <listitem> 627 <para> 628 <function>gin_page_opaque_info</function> returns information about 629 a <acronym>GIN</acronym> index opaque area, like the page type. 630 For example: 631<screen> 632test=# SELECT * FROM gin_page_opaque_info(get_raw_page('gin_index', 2)); 633 rightlink | maxoff | flags 634-----------+--------+------------------------ 635 5 | 0 | {data,leaf,compressed} 636(1 row) 637</screen> 638 </para> 639 </listitem> 640 </varlistentry> 641 642 <varlistentry> 643 <term> 644 <function>gin_leafpage_items(page bytea) returns setof record</function> 645 <indexterm> 646 <primary>gin_leafpage_items</primary> 647 </indexterm> 648 </term> 649 650 <listitem> 651 <para> 652 <function>gin_leafpage_items</function> returns information about 653 the data stored in a <acronym>GIN</acronym> leaf page. For example: 654<screen> 655test=# SELECT first_tid, nbytes, tids[0:5] AS some_tids 656 FROM gin_leafpage_items(get_raw_page('gin_test_idx', 2)); 657 first_tid | nbytes | some_tids 658-----------+--------+---------------------------------------------------------- 659 (8,41) | 244 | {"(8,41)","(8,43)","(8,44)","(8,45)","(8,46)"} 660 (10,45) | 248 | {"(10,45)","(10,46)","(10,47)","(10,48)","(10,49)"} 661 (12,52) | 248 | {"(12,52)","(12,53)","(12,54)","(12,55)","(12,56)"} 662 (14,59) | 320 | {"(14,59)","(14,60)","(14,61)","(14,62)","(14,63)"} 663 (167,16) | 376 | {"(167,16)","(167,17)","(167,18)","(167,19)","(167,20)"} 664 (170,30) | 376 | {"(170,30)","(170,31)","(170,32)","(170,33)","(170,34)"} 665 (173,44) | 197 | {"(173,44)","(173,45)","(173,46)","(173,47)","(173,48)"} 666(7 rows) 667</screen> 668 </para> 669 </listitem> 670 </varlistentry> 671 </variablelist> 672 </sect2> 673 674 <sect2> 675 <title>Hash Functions</title> 676 677 <variablelist> 678 <varlistentry> 679 <term> 680 <function>hash_page_type(page bytea) returns text</function> 681 <indexterm> 682 <primary>hash_page_type</primary> 683 </indexterm> 684 </term> 685 686 <listitem> 687 <para> 688 <function>hash_page_type</function> returns page type of 689 the given <acronym>HASH</acronym> index page. For example: 690<screen> 691test=# SELECT hash_page_type(get_raw_page('con_hash_index', 0)); 692 hash_page_type 693---------------- 694 metapage 695</screen> 696 </para> 697 </listitem> 698 </varlistentry> 699 700 <varlistentry> 701 <term> 702 <function>hash_page_stats(page bytea) returns setof record</function> 703 <indexterm> 704 <primary>hash_page_stats</primary> 705 </indexterm> 706 </term> 707 708 <listitem> 709 <para> 710 <function>hash_page_stats</function> returns information about 711 a bucket or overflow page of a <acronym>HASH</acronym> index. 712 For example: 713<screen> 714test=# SELECT * FROM hash_page_stats(get_raw_page('con_hash_index', 1)); 715-[ RECORD 1 ]---+----------- 716live_items | 407 717dead_items | 0 718page_size | 8192 719free_size | 8 720hasho_prevblkno | 4096 721hasho_nextblkno | 8474 722hasho_bucket | 0 723hasho_flag | 66 724hasho_page_id | 65408 725</screen> 726 </para> 727 </listitem> 728 </varlistentry> 729 730 <varlistentry> 731 <term> 732 <function>hash_page_items(page bytea) returns setof record</function> 733 <indexterm> 734 <primary>hash_page_items</primary> 735 </indexterm> 736 </term> 737 738 <listitem> 739 <para> 740 <function>hash_page_items</function> returns information about 741 the data stored in a bucket or overflow page of a <acronym>HASH</acronym> 742 index page. For example: 743<screen> 744test=# SELECT * FROM hash_page_items(get_raw_page('con_hash_index', 1)) LIMIT 5; 745 itemoffset | ctid | data 746------------+-----------+------------ 747 1 | (899,77) | 1053474816 748 2 | (897,29) | 1053474816 749 3 | (894,207) | 1053474816 750 4 | (892,159) | 1053474816 751 5 | (890,111) | 1053474816 752</screen> 753 </para> 754 </listitem> 755 </varlistentry> 756 757 <varlistentry> 758 <term> 759 <function>hash_bitmap_info(index oid, blkno int) returns record</function> 760 <indexterm> 761 <primary>hash_bitmap_info</primary> 762 </indexterm> 763 </term> 764 765 <listitem> 766 <para> 767 <function>hash_bitmap_info</function> shows the status of a bit 768 in the bitmap page for a particular overflow page of <acronym>HASH</acronym> 769 index. For example: 770<screen> 771test=# SELECT * FROM hash_bitmap_info('con_hash_index', 2052); 772 bitmapblkno | bitmapbit | bitstatus 773-------------+-----------+----------- 774 65 | 3 | t 775</screen> 776 </para> 777 </listitem> 778 </varlistentry> 779 780 <varlistentry> 781 <term> 782 <function>hash_metapage_info(page bytea) returns record</function> 783 <indexterm> 784 <primary>hash_metapage_info</primary> 785 </indexterm> 786 </term> 787 788 <listitem> 789 <para> 790 <function>hash_metapage_info</function> returns information stored 791 in the meta page of a <acronym>HASH</acronym> index. For example: 792<screen> 793test=# SELECT magic, version, ntuples, ffactor, bsize, bmsize, bmshift, 794test-# maxbucket, highmask, lowmask, ovflpoint, firstfree, nmaps, procid, 795test-# regexp_replace(spares::text, '(,0)*}', '}') as spares, 796test-# regexp_replace(mapp::text, '(,0)*}', '}') as mapp 797test-# FROM hash_metapage_info(get_raw_page('con_hash_index', 0)); 798-[ RECORD 1 ]-------------------------------------------------&zwsp;------------------------------ 799magic | 105121344 800version | 4 801ntuples | 500500 802ffactor | 40 803bsize | 8152 804bmsize | 4096 805bmshift | 15 806maxbucket | 12512 807highmask | 16383 808lowmask | 8191 809ovflpoint | 28 810firstfree | 1204 811nmaps | 1 812procid | 450 813spares | {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} 814mapp | {65} 815</screen> 816 </para> 817 </listitem> 818 </varlistentry> 819 </variablelist> 820 </sect2> 821 822</sect1> 823