Re: Physical column size - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: Physical column size
Date
Msg-id 200603031123.22453.peter_e@gmx.net
Whole thread Raw
In response to Physical column size  ("Paul Mackay" <mackaypaul@gmail.com>)
Responses Re: Physical column size
List pgsql-general
Am Freitag, 3. März 2006 11:03 schrieb Paul Mackay:
> I've created a table like this :
> CREATE TABLE tmp_A (
> c "char",
> i int4
> );
>
> And another one
> CREATE TABLE tmp_B (
> i int4,
> ii int4
> );

> The end result is that the physical size on disk used by table tmp_A is
> exactly the same as table tmp_B (as revealed by the pg_relation_size
> function) !

An int4 field is required to be aligned at a 4-byte boundary internally, so
there are 3 bytes wasted between tmp_A.c and tmp_A.i.  If you switch the
order of the fields you should see space savings.  (Note, however, that the
per-row overhead is about 32 bytes, so you'll probably only save about 10%
overall, rather than the 37.5% that one might expect.)

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

pgsql-general by date:

Previous
From: Csaba Nagy
Date:
Subject: Re: query timeout
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Physical column size