From: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-general@postgresql.org
Cc: Paul Mackay <mackaypaul@gmail.com>
Subject: Re: Physical column size
Date: Fri, 3 Mar 2006 11:23:21 +0100
Message-ID: <200603031123.22453.peter_e@gmx.net> (raw)
In-Reply-To: <786c2f6d0603030203m3b7c62a1k6950ceca066dc5ce@mail.gmail.com>
References: <786c2f6d0601260206k2201a548p48af7c7fc085d3b2@mail.gmail.com>
<786c2f6d0603030203m3b7c62a1k6950ceca066dc5ce@mail.gmail.com>
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/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: peter_e@gmx.net, pgsql-general@postgresql.org, mackaypaul@gmail.com
Subject: Re: Physical column size
In-Reply-To: <200603031123.22453.peter_e@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox