Re: Disk space usage

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
Cc: Joe Bloggs <polonium210(at)googlemail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Disk space usage
Date: 2006-11-29 21:25:45
Message-ID: 4664.1164835545@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Scott Marlowe <smarlowe(at)g2switchworks(dot)com> writes:
> On Wed, 2006-11-29 at 13:57, Joe Bloggs wrote:
>> I created a table in 8.1.5 on Linux with three columns;
>> date, bigint and integer.
>>
>> I looked at the size of the file that contained the table and divided
>> this by the number of rows which gave an average of just over 60 bytes
>> per row.
>>
>> This seems to be quite a large overhead as I would guess that the date
>> field takes around 4 bytes, the bigint 8 bytes and the integer 4
>> bytes. I would have hoped to have had an average size of between 20
>> and 30 bytes per row.

> Had you done any updates to the tables?

I think it's about dead on, if he's using a machine with MAXALIGN 8:

Row's item pointer 4 bytes
Row header 32 bytes (including alignment padding)
date column 4 bytes
alignment padding 4 bytes
bigint column 8 bytes
integer column 4 bytes
alignment padding 4 bytes
--------
60 bytes

The choice of column order is unfortunate --- if he'd put the bigint
column either first or last, there wouldn't be the alignment penalties.

Hopefully we'll be able to get the row header back down to 24 bytes in
8.3, but it's never going to be the 4-or-so-bytes that the OP is
imagining.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2006-11-29 21:32:54 Re: Out of file-descriptors message
Previous Message John Allgood 2006-11-29 21:04:40 Out of file-descriptors message