Re: Size comparison between a Composite type and an - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Size comparison between a Composite type and an
Date
Msg-id 20060301173755.GA17845@svana.org
Whole thread Raw
In response to Re: Size comparison between a Composite type and an  (denis@edistar.com)
List pgsql-general
On Wed, Mar 01, 2006 at 05:24:03PM +0100, denis@edistar.com wrote:
> I made some tests with three different types:
>
> numeric, text and a specialized type written in c.
>
> The tests were made with 20 digit codes.

<snip>

> The results were not as expected.
>
> I was expecting these theoretical results:
> mycode: 1.000.000 of records =>  12.000.000 bytes
> numeric: 1.000.000 of records => 18.000.000 bytes
> text: 1.000.000 of records => 24.000.000 bytes
>
> That is the final size of the table with the text data type to be the
> double of mycode type.
>
> The real results were:
> mycode: 1.000.000 of records =>  65.159.168 bytes
> numeric: 1.000.000 of records => 74.895.702 bytes
> text: 1.000.000 of records => 77.340.672 bytes
>
> The "text" table is only 16% larger than mycode one (I was expecting 100%!).

You're missing the per-tuple overhead which is approximatly 28 bytes.
Once you take alignment into account, it's not surprising the results
are closer than you expected.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.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.

Attachment

pgsql-general by date:

Previous
From: "Roger Hand"
Date:
Subject: Re: Looking for a fix to index bloat
Next
From: "Florian G. Pflug"
Date:
Subject: [OFFTOPIC] Typo3 + Postgresql anyone?