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 1t3OVq-00CJxF-34 for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Oct 2024 23:42:06 +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 1t3OVo-004KjE-B7 for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Oct 2024 23:42:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3OVo-004Kj6-1I for pgsql-hackers@lists.postgresql.org; Tue, 22 Oct 2024 23:42:04 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t3OVl-002MaR-QG for pgsql-hackers@lists.postgresql.org; Tue, 22 Oct 2024 23:42:03 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-277e6002b7dso2303736fac.1 for ; Tue, 22 Oct 2024 16:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729640521; x=1730245321; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Cckkj/xMKAOHtL73wpliTz3Zp8TlXJs8PaY2wNDXCnc=; b=GwGwynt2oGt/2SX2OenA1CHGcgi06XPAUb5aeiBtwCS+RQFkRy1GriW1ZPjWaByIao 8fAz6ioODQ0EQPkyWIV4mZSW+Gv/Qj/CNDC0b+/K5CtuWXlc3j61Ej9SkLc9MXjiwrr4 ANhzwSASzEOXT0bzU1K05UClzMlapik2SEUYDsTz3X9DvP7ZlfJVZX4WDhPRDXOX3s1b e7tFsERM89+O+2JoHi1O0Ksy3M/9n2YpwvHSfmp6FPg4prTAQOPSj4REj3GuC6yUh2J1 8ZM0nBjOcBcV/O4n0o0CExyzcm9N4O4BcPJdUxvmpXJKF+APsUIkTESlAiK1CkBKOWyj 0EzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729640521; x=1730245321; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cckkj/xMKAOHtL73wpliTz3Zp8TlXJs8PaY2wNDXCnc=; b=h2MDv/RNtL3GinBCPxfDTp/BfsW5Swuw6AYp8TXYoDDT5WEjsGsDKhIfKJ0/L22bVt rngcKGVI5NjzpOIRrOxGUDkDjleTzURnOzVLYtJDmNlHCghYsQT0pAcbMPWjAQ8wCFk5 Rlltx7tD9iK6UjPlLbBN/8W3xwejt7I9anRnnGpzfYp8eTnADm6PEgMThtRB0A6xfHtq K5wV6I/0H+LsOBKuKCV+FhXg6+PbATu3VUBKsN/XA0fh8jJNCN+JX/yWPk2hCtfDWDSt Aahaf8RfP94e1twc+0uWMJVhhq/L88rst8G6xwXihaCUvjyKEJYLEvkFqfM7FSKqBuks tInA== X-Forwarded-Encrypted: i=1; AJvYcCV2IV1qqNbXNRxH8Qko092dFyjmakz5qj0X8COYZNlDKxniMhFLmGOoys/VBJ8mDyTpuIKyRtesMiCV3Ta9@lists.postgresql.org X-Gm-Message-State: AOJu0YxLqJZPdQ1E68GHIfWzyv6h/Oyyg1eMpaLFq8laD+ceBt0ahXp5 ejms7QkflWlk9BkRqVFbRqd74FgfB1nX0iGl/OI94wUmctudA2zI0q5cdIztbLaVrmbszZ3EAmK lYYPHRXKWT+Q0dVn13OOubA0bcNc= X-Google-Smtp-Source: AGHT+IFvHvhfEC0oi4LZohMAuV87zDL33r7lwjbo47qvaj8oiVs/BEaYT3un1Ww+qvhzjoT3WqaoocpIQZ8xzhJ4RCQ= X-Received: by 2002:a05:6870:b4a9:b0:261:22a4:9235 with SMTP id 586e51a60fabf-28ccb985595mr936257fac.32.1729640520738; Tue, 22 Oct 2024 16:42:00 -0700 (PDT) MIME-Version: 1.0 References: <2093063.1729636492@sss.pgh.pa.us> In-Reply-To: From: "David G. Johnston" Date: Tue, 22 Oct 2024 16:41:22 -0700 Message-ID: Subject: Re: Unexpected table size usage for small composite arrays To: Erik Sjoblom Cc: Tom Lane , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000d3ef1a06251950e7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d3ef1a06251950e7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Oct 22, 2024 at 3:46=E2=80=AFPM 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. 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. --000000000000d3ef1a06251950e7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Oct 22, 2024 at 3:46=E2=80=AFPM Erik Sjoblom <<= a href=3D"mailto:sjoblom65@gmail.com">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.=C2=A0 That is a faulty assumption.=C2=A0 A= user created custom type always takes some overhead because it is consider= ed a variable structure, even in the case where all of its fields are fixed= -width.=C2=A0 Furthermore, it is self-describing, and so that description h= as to go somewhere.=C2=A0 Therefore, there must be a non-zero per-element o= verhead to store composite values within an array.=C2=A0 As Tom told you, t= he specific non-zero number is 24 bytes.

David J.

--000000000000d3ef1a06251950e7--