Re: Size comparison between a Composite type and an

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: denis(at)edistar(dot)com
Cc: Douglas McNaught <doug(at)mcnaught(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Size comparison between a Composite type and an
Date: 2006-03-01 17:37:55
Message-ID: 20060301173755.GA17845@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 01, 2006 at 05:24:03PM +0100, denis(at)edistar(dot)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(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 Florian G. Pflug 2006-03-01 18:11:49 [OFFTOPIC] Typo3 + Postgresql anyone?
Previous Message Roger Hand 2006-03-01 17:32:24 Re: Looking for a fix to index bloat