jsonb on-disk size calculation

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: jsonb on-disk size calculation
Date: 2023-07-31 11:10:24
Message-ID: CACJufxFRxk7bi_Ez3OTL4PKF_ODrX5xfY_VR8SX=uqMQTVA9wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hi.

drop table x;
create table x(js jsonb);
insert into x select '{"Hello world":1}'::jsonb;
select pg_column_size(js) from x; -- return 33.

based on src/include/utils/jsonb.h
The key and value part is 20 bytes (is it correct?), Jsonb->vl_len_ is 4
byte, JsonbContainer->header is 4 bytes. That's 28 bytes.

but now on-disk is 33 bytes.
so I am not sure where the remaining bytes are.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex Shan 2023-07-31 12:14:31 Re: How to get an md5/sha256 hash of a really large object in psql?
Previous Message Priess Stefan 2023-07-31 08:16:14 AW: AW: Compile static postgres.lib for postgres 15.3 on Windows