Thread: stored short varlena in array

stored short varlena in array

From
Quan Zongliang
Date:
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