Re: PostgreSQL Disk Usage and Page Size

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Seum-Lim Gan <slgan(at)lucent(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org, ahsaleh(at)lucent(dot)com
Subject: Re: PostgreSQL Disk Usage and Page Size
Date: 2004-03-18 00:18:02
Message-ID: 20040317160012.G32224@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 17 Mar 2004, Seum-Lim Gan wrote:

> we have a question about the pagesize in PostgreSQL:
>
> Using different pagesizes: 4K, 8K, 16K, 32K, when we store different
> record sizes
> such as in the following example:
>
> CREATE TABLE TEST_1 (
> F1 VARCHAR(10),
> F2 VARCHAR(5) );
>
> CREATE TABLE TEST_2 (
> F1 VARCHAR(10),
> F2 VARCHAR(10) );
>
> we're consistently having the following storage behavior:
>
> 60 records / 4k_page
> 120 records / 8k_page
> 240 records / 16k_page
> 480 records / 32k_page.
>
> So it seems that it doesn't matter whether the record size is
> 15 bytes or 20 bytes, there's maximum number of records per page
> as shown above.

The rows aren't 15 or 20 bytes, they're something closer to:

row header (24 bytes?) + f1 length (4 bytes) + actual bytes for f1 +
f2 length (4 bytes) + actual bytes for f2
(I'm not sure about additional padding, but there's probably some to word
boundaries)

And since you're using varchar, you won't see an actual row size
difference unless you're using different data between the two tables.

If you're in a one byte encoding and putting in maximum length strings,
I'd expect something like 52 and 56 bytes for the above two tables.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2004-03-18 05:03:47 Re: severe performance issue with planner (fwd)
Previous Message Stephen Robert Norris 2004-03-18 00:07:35 Re: PostgreSQL Disk Usage and Page Size