| From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Cc: | "Paul Mackay" <mackaypaul(at)gmail(dot)com> |
| Subject: | Re: Physical column size |
| Date: | 2006-03-03 10:23:21 |
| Message-ID: | 200603031123.22453.peter_e@gmx.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general pgsql-performance pgsql-sql |
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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martijn van Oosterhout | 2006-03-03 10:23:58 | Re: Physical column size |
| Previous Message | Csaba Nagy | 2006-03-03 10:14:20 | Re: query timeout |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martijn van Oosterhout | 2006-03-03 10:23:58 | Re: Physical column size |
| Previous Message | Paul Mackay | 2006-03-03 10:03:24 | Physical column size |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Martijn van Oosterhout | 2006-03-03 10:23:58 | Re: Physical column size |
| Previous Message | Paul Mackay | 2006-03-03 10:03:24 | Physical column size |