Re: database size estimates

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Francois Deliege <fdeliege(at)cs(dot)aau(dot)dk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: database size estimates
Date: 2007-04-25 14:24:53
Message-ID: 462F64B5.8000900@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Francois Deliege wrote:
> Hi,
>
> I am trying to estimate the size of a table composed of 51754000 rows.
> Each row has 31 attributes: 16 x bit(24) and 15 x bit(8)
>
> So, the payload should be:
> 51754000 x ( 16 x 24 + 15 x 24 ) bits = 3115 MB

What data types are those exactly? If those 24-bit fields are in fact
text, varchar, char(x) or other data types that are stored as variable
length fields, the varlen header will take 4 bytes. And then there's
alignment, those 24-bit fields are most almost certainly 4-byte aligned,
which means that there'll be one byte of padding between them.

The upcoming 8.3 release will be much better in that respect, It'll use
just a 1 byte varlen header per field instead of 4 bytes for small
values like yours. You might want to test a CVS snapshot.

> Now, from what I understand from postgresql manual is that the overhead
> is composed of
> 32 bytes per row + 20 bytes per page.
> This leads me to approx. 1700 MB overhead.
> Therefore a total table size of 4900 MB.

In addition, there will be on average 1/2 rows worth of wasted space on
every page.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mageshwaran 2007-04-25 14:33:37 Kill a Long Running Query
Previous Message Dave Page 2007-04-25 14:17:58 Re: ECPG failure on BF member Vaquita (Windows Vista)