Re: Unexpected table size usage for small composite arrays - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Unexpected table size usage for small composite arrays
Date
Msg-id CAKFQuwa32sJfr+OUrFX8VpfkoNXdRidK93RmLExz_4s-demBrA@mail.gmail.com
Whole thread Raw
In response to Re: Unexpected table size usage for small composite arrays  (Erik Sjoblom <sjoblom65@gmail.com>)
List pgsql-hackers
On Tue, Oct 22, 2024 at 3:46 PM Erik Sjoblom <sjoblom65@gmail.com> wrote:

Yes, I did expect that the first element should take 24+12 bytes and let's round that to 50 bytes.

Assuming the 24 is coming from the array overhead you are expecting that storing a custom composite typed value takes zero overhead.  That is a faulty assumption.  A user created custom type always takes some overhead because it is considered a variable structure, even in the case where all of its fields are fixed-width.  Furthermore, it is self-describing, and so that description has to go somewhere.  Therefore, there must be a non-zero per-element overhead to store composite values within an array.  As Tom told you, the specific non-zero number is 24 bytes.

David J.

pgsql-hackers by date:

Previous
From: Erik Sjoblom
Date:
Subject: Re: Unexpected table size usage for small composite arrays
Next
From: "David G. Johnston"
Date:
Subject: Re: Unexpected table size usage for small composite arrays