Re: Unexpected table size usage for small composite arrays

2024-10-23 Thread Erik Sjoblom
Thank you both for explaining this! Tom, your statement sounds like a good solution: " In principle we could squeeze those out and store them only once per array, but we don't." On Tue, Oct 22, 2024 at 8:44 PM Tom Lane wrote: > "David G. Johnston" writes: > > On Tue, Oct 22, 2024 at 4:40 PM E

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread Tom Lane
"David G. Johnston" writes: > On Tue, Oct 22, 2024 at 4:40 PM Erik Sjoblom wrote: >> I hear what you are saying Tom and what I have read says that it would >> take 24 + 12 x N bytes for the array. > Whatever you are reading, or your interpretation of it, is flawed. I wonder whether Erik is conf

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread David G. Johnston
On Tue, Oct 22, 2024 at 4:42 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tue, Oct 22, 2024 at 4:40 PM Erik Sjoblom wrote: > >> I hear what you are saying Tom and what I have read says that it would >> take 24 + 12 x N bytes for the array. >> > > Whatever you are reading, or you

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread David G. Johnston
On Tue, Oct 22, 2024 at 4:40 PM Erik Sjoblom wrote: > I hear what you are saying Tom and what I have read says that it would > take 24 + 12 x N bytes for the array. > Whatever you are reading, or your interpretation of it, is flawed. David J.

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread David G. Johnston
On Tue, Oct 22, 2024 at 3:46 PM Erik Sjoblom 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. Tha

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread Erik Sjoblom
I hear what you are saying Tom and what I have read says that it would take 24 + 12 x N bytes for the array. This isn't the case when I start adding elements to the table. Here are some samples adding 10,000 rows with difference elements in the composite array: Row countArray elementsMain table si

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread Tom Lane
Erik Sjoblom writes: > I don't see why it's using 50 bytes per element. There should be just one > 24 byte header for the array, not one per element [ shrug... ] I just told you that's not so. regards, tom lane

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread Erik Sjoblom
Thanks Tom for your response! Yes, I did expect that the first element should take 24+12 bytes and let's round that to 50 bytes. If I store another element, I would expect another 12. (or 16 depending on padding) and take say ~65 bytes. I'm seeing close to 100 bytes. If I have 3 elements, it's usi

Re: Unexpected table size usage for small composite arrays

2024-10-22 Thread Tom Lane
Erik Sjoblom writes: > I’m observing a storage behavior with arrays in a table that differs from > my expectations, and I’d appreciate your insights. I was to store key value > pairs in a very dense data model. I don't haver the requirement of search > so that's why I was thinking an array of a co