8000 Improve documentation of bt_page_items(). · easonzhou/postgres@ebc0f5e · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ebc0f5e

Browse files
committed
Improve documentation of bt_page_items().
Explain some of the funny conventions used in btree page items. Peter Geoghegan and Jeff Janes
1 parent 443fd05 commit ebc0f5e
Copy full SHA for ebc0f5e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

doc/src/sgml/pageinspect.sgml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,21 @@ test=# SELECT * FROM bt_page_items('pg_cast_oid_index', 1);
192192
7 | (0,7) | 12 | f | f | 29 27 00 00
193193
8 | (0,8) | 12 | f | f | 2a 27 00 00
194194
</screen>
195+
In a B-tree leaf page, <structfield>ctid</> points to a heap tuple.
196+
In an internal page, the block number part of <structfield>ctid</>
197+
points to another page in the index itself, while the offset part
198+
(the second number) is ignored and is usually 1.
199+
</para>
200+
<para>
201+
Note that the first item on any non-rightmost page (any page with
202+
a non-zero value in the <structfield>btpo_next</> field) is the
203+
page's <quote>high key</quote>, meaning its <structfield>data</>
204+
serves as an upper bound on all items appearing on the page, while
205+
its <structfield>ctid</> field is meaningless. Also, on non-leaf
206+
pages, the first real data item (the first item that is not a high
207+
key) is a <quote>minus infinity</quote> item, with no actual value
208+
in its <structfield>data</> field. Such an item does have a valid
209+
downlink in its <structfield>ctid</> field, however.
195210
</para>
196211
</listitem>
197212
</varlistentry>
@@ -369,8 +384,7 @@ test=# SELECT * FROM gin_page_opaque_info(get_raw_page('gin_index', 2));
369384
<screen>
370385
test=# SELECT first_tid, nbytes, tids[0:5] as some_tids
371386
FROM gin_leafpage_items(get_raw_page('gin_test_idx', 2));
372-
first_tid | nbytes | some_tids
373-
387+
first_tid | nbytes | some_tids
374388
-----------+--------+----------------------------------------------------------
375389
(8,41) | 244 | {"(8,41)","(8,43)","(8,44)","(8,45)","(8,46)"}
376390
(10,45) | 248 | {"(10,45)","(10,46)","(10,47)","(10,48)","(10,49)"}

0 commit comments

Comments
 (0)
0