Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3NSw-00CECI-46 for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Oct 2024 22:35:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3NSt-003qDP-0m for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Oct 2024 22:34:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3NSs-003qDD-MY for pgsql-hackers@lists.postgresql.org; Tue, 22 Oct 2024 22:34:59 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3NSq-002SeT-ND for pgsql-hackers@lists.postgresql.org; Tue, 22 Oct 2024 22:34:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 49MMYqjE2093064; Tue, 22 Oct 2024 18:34:52 -0400 From: Tom Lane To: Erik Sjoblom cc: pgsql-hackers@lists.postgresql.org Subject: Re: Unexpected table size usage for small composite arrays In-reply-to: References: Comments: In-reply-to Erik Sjoblom message dated "Tue, 22 Oct 2024 17:58:29 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2093062.1729636492.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 22 Oct 2024 18:34:52 -0400 Message-ID: <2093063.1729636492@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erik Sjoblom writes: > I=E2=80=99m observing a storage behavior with arrays in a table that dif= fers from > my expectations, and I=E2=80=99d appreciate your insights. I was to stor= e key value > pairs in a very dense data model. I don't haver the requirement of searc= h > so that's why I was thinking an array of a composite type would work wel= l. > I can see that padding might be involved using the int4 and int8 > combination but there is more overhead. Anyone know where the following = it > coming from? Composite values use the same 24-byte tuple headers as table rows do. So you'd be looking at 40 bytes per array element in this example. A large array of them would probably compress pretty well, but it's never going to be cheap. Can you store the int4's and int8's in two parallel arrays? regards, tom lane