0
-- https://doxygen.postgresql.org/btreefuncs_8c_source.html#l00625
CREATE TABLE s2 AS  SELECT  g::int AS g FROM generate_series(1, 10000) g;
ALTER TABLE s2 ADD PRIMARY KEY (g);

SELECT root,level FROM bt_metap ('s2_pkey');

SELECT * FROM bt_page_stats ('s2_pkey', 3) gx

SELECT  itemoffset,itemlen,ctid
        ,pg_column_size(ctid) ctid_size,data
        ,pg_column_size(data) size_data
FROM    bt_page_items ('s2_pkey', 3)
ORDER BY    itemoffset LIMIT 10;

returns

 itemoffset | itemlen |  ctid  | ctid_size |          data           | size_data
------------+---------+--------+-----------+-------------------------+-----------
          1 |       8 | (1,0)  |         6 |                         |         1
          2 |      16 | (2,1)  |         6 | 6f 01 00 00 00 00 00 00 |        24
          3 |      16 | (4,1)  |         6 | dd 02 00 00 00 00 00 00 |        24
          4 |      16 | (5,1)  |         6 | 4b 04 00 00 00 00 00 00 |        24
          5 |      16 | (6,1)  |         6 | b9 05 00 00 00 00 00 00 |        24
          6 |      16 | (7,1)  |         6 | 27 07 00 00 00 00 00 00 |        24
          7 |      16 | (8,1)  |         6 | 95 08 00 00 00 00 00 00 |        24
          8 |      16 | (9,1)  |         6 | 03 0a 00 00 00 00 00 00 |        24
          9 |      16 | (10,1) |         6 | 71 0b 00 00 00 00 00 00 |        24
         10 |      16 | (11,1) |         6 | df 0c 00 00 00 00 00 00 |        24
(10 rows)

I wonder what does the itemlen 16 mean?

1 Answer 1

1

itemlen is simply the size of the index entry. There are 8 bytes of data and 6 bytes for the ctid, and that gets rounded up to the next multiple of eight. So the size is 16 bytes.

The first item is the “high key” which has no data, so the size is 8 there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.