Re: Physical column size

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
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:23:58
Message-ID: 20060303102358.GA17615@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance pgsql-sql

On Fri, Mar 03, 2006 at 11:03:24AM +0100, Paul Mackay wrote:
> 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 ?

Alignment. An int4 value must start on a multiple of 4 offset, so you
get three bytes of padding. If you put the int4, then the char it
should work better. Although whole rows have alignment requirements
too...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ragnar 2006-03-03 10:27:59 Re: Physical column size
Previous Message Peter Eisentraut 2006-03-03 10:23:21 Re: Physical column size

Browse pgsql-performance by date

  From Date Subject
Next Message Ragnar 2006-03-03 10:27:59 Re: Physical column size
Previous Message Peter Eisentraut 2006-03-03 10:23:21 Re: Physical column size

Browse pgsql-sql by date

  From Date Subject
Next Message Ragnar 2006-03-03 10:27:59 Re: Physical column size
Previous Message Peter Eisentraut 2006-03-03 10:23:21 Re: Physical column size