stored short varlena in array

From: Quan Zongliang <quanzongliang(at)yeah(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: quanzl(at)highgo(dot)com
Subject: stored short varlena in array
Date: 2024-12-25 06:29:12
Message-ID: 2cc374ae-1aa4-449f-9fb4-41133b37d8a8@yeah.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi

Now, the varlena type is stored directly in the array. Did not consider
short varlena. If it's like fill_val(), using short varlena saves memory
footprint and disk space.
In TODO, there is a requirement to be implemented:
Allow single-byte header storage for array elements

This patch modifies many files.
Based on 38da053463bef32adf563ddee5277d16d2b6c5af
Has passed the regression test.
But it can affect many contribs. The code needs to be adjusted. Like
hstore and ltree.

Disk space usage test

create table t1 (c1 varchar[]);
insert into t1
select '{a,b,c,d,e,f,g,h,i,j,k,l,m,n}'
from generate_series(1,100000);
select pg_relation_size('t1')/8192;

before
postgres=# select pg_relation_size('t1')/8192;
?column?
----------
2041
(1 row)

after
postgres=# select pg_relation_size('t1')/8192;
?column?
----------
1334
(1 row)

Memory usage
'{a,b,c,d,e,f,g,h,i,j,k,l,m,n}'::varchar[]

before
136 bytes
after
80 bytes

--
Zongliang Quan

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Quan Zongliang 2024-12-25 06:32:51 Re: stored short varlena in array
Previous Message Andrei Lepikhov 2024-12-25 06:06:52 Re: Short-living Memory Context in the optimiser