Thread: pageinspect bt_page_items doc

pageinspect bt_page_items doc

From
jian he
Date:
hi.

https://www.postgresql.org/docs/current/pageinspect.html#id-1.11.7.34.6

> This is a B-tree leaf page. All tuples that point to the table happen to be posting list tuples (all of which store a
totalof 100 6 byte TIDs). 
> There is also a “high key” tuple at itemoffset number 1. ctid is used to store encoded information about each tuple
inthis example, though 
> leaf page tuples often store a heap TID directly in the ctid field instead. tids is the list of TIDs stored as a
postinglist. 

(all of which store a total of 100 6 byte TIDs)
I think the meaning is something like:
(all of which store a total of 100 TIDs, each TID is 6 byte long.)

 What's the meaning of  (16, 8292)?  After looking around. I'm still confused.
Would it be better to add an explanation about (16, 8292) to the docs?



Re: pageinspect bt_page_items doc

From
Julien Rouhaud
Date:
Hi,

On Mon, Jul 24, 2023 at 08:57:05AM +0800, jian he wrote:
> hi.
>
> https://www.postgresql.org/docs/current/pageinspect.html#id-1.11.7.34.6
>
> > This is a B-tree leaf page. All tuples that point to the table happen to be posting list tuples (all of which store
atotal of 100 6 byte TIDs).
 
> > There is also a “high key” tuple at itemoffset number 1. ctid is used to store encoded information about each tuple
inthis example, though
 
> > leaf page tuples often store a heap TID directly in the ctid field instead. tids is the list of TIDs stored as a
postinglist.
 
>
> (all of which store a total of 100 6 byte TIDs)
> I think the meaning is something like:
> (all of which store a total of 100 TIDs, each TID is 6 byte long.)

Yes that's what it means.

>  What's the meaning of  (16, 8292)?  After looking around. I'm still confused.
> Would it be better to add an explanation about (16, 8292) to the docs?

I'm not sure how easy it would be to document it.  If you want more detail
about "encoded information about each tuple" you need to look at the btree
implementation, in src/include/access/nbtree.h.

For instance, to get the number of items in a posting list, you see the
BTreeTupleGetNPosting() function, which basically returns ctid & 0X0FFF.  And
8292 & 0X0FFF is 100, which is the mentioned number of tids.  If you look
around line 462 of the same file (near the BT_OFFSET_MASK) you will see all the
other usage for the ctid in case of a posting list, like knowing whether the
IndexTuple is a posting list of not.