From: | Ragnar <gnari(at)hive(dot)is> |
---|---|
To: | Paul Mackay <mackaypaul(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Physical column size |
Date: | 2006-03-03 10:27:59 |
Message-ID: | 1141381679.18656.141.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-performance pgsql-sql |
On fös, 2006-03-03 at 11:03 +0100, Paul Mackay wrote:
> Hi,
>
> 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
> );
>
> I then inserted a bit more than 19 million rows in each table (exactly
> the same number of rows in each).
>
> 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) ! Given that a "char" field is supposed to
> be 1 byte in size and a int4 4 bytes, shouldn't the tmp_A use a
> smaller disk space ? Or is it that any value, whatever the type,
> requires at least 4 bytes to be stored ?
the int4 needs to be aligned at 4 bytes boundaries,
making wasted space after the char.
this would probably be the same size:
CREATE TABLE tmp_C (
c "char",
cc "char",
i int4
);
and this would be smaller:
CREATE TABLE tmp_D (
c "char",
cc "char",
ccc "char",
);
P.S.: I did not actually check to
see if the "char" type needs to be aligned,
by I assumed not.
From | Date | Subject | |
---|---|---|---|
Next Message | Agnes Bocchino | 2006-03-03 10:54:21 | Re: Question about the contrib rpm ? |
Previous Message | Martijn van Oosterhout | 2006-03-03 10:23:58 | Re: Physical column size |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-03-03 14:53:47 | Re: Physical column size |
Previous Message | Martijn van Oosterhout | 2006-03-03 10:23:58 | Re: Physical column size |
From | Date | Subject | |
---|---|---|---|
Next Message | Joost Kraaijeveld | 2006-03-03 10:42:58 | Re: Why do I get these results????? |
Previous Message | Martijn van Oosterhout | 2006-03-03 10:23:58 | Re: Physical column size |