Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nK300-0005SP-Hu for pgsql-docs@arkaria.postgresql.org; Tue, 15 Feb 2022 18:56:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nK2zz-000598-H4 for pgsql-docs@arkaria.postgresql.org; Tue, 15 Feb 2022 18:56:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nK2uT-0002Sn-8t for pgsql-docs@lists.postgresql.org; Tue, 15 Feb 2022 18:50:45 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nK2uQ-0002bL-Hc for pgsql-docs@lists.postgresql.org; Tue, 15 Feb 2022 18:50:44 +0000 Received: by mail-io1-xd30.google.com with SMTP id t6so2444327ioj.12 for ; Tue, 15 Feb 2022 10:50:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pm3/Foso/axo571uZ1Xwuw+JJ7Vx+irjzYh4alkFvLE=; b=Onfu8GDoaKFEJQS9tDNYeW2kSTKDb4QC5uGnxW8xhgAM9BtJi16F4MpFnJQNujD39F ZlUBpb7WSQrLzTU/qZOTz3A8MeFUf7sdqSeMA0eVFTrnu1TkdxSOsXFPrAlqahxvqzsU YD3ZNddWK0avq69IuNVOyM21T/aysPKr5/IYUwdMChCk0yeP45W3W/UprNBuZzNjcA8y YXQSqVvtF2St1ucq0tnwICw0pm1cx1lT+rapuCIb/hc02sPhLZbCu+mjTFGpMkY9FG6v CAp4KlxX1hT1qD6krfloo9eIQSUuLe4zKPkIFCZOQmn8yMfev3faYv+Drja8mwEiHZdr 4VRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pm3/Foso/axo571uZ1Xwuw+JJ7Vx+irjzYh4alkFvLE=; b=C5STgki1pZLghClxdzcPB82x/xxgZVcSsiQs2PwsPEoLGHwvNrPaebQI+D43L3yGXN 1RZk/ccFIMhqcmIOtXQP8AFn+dO3WnUDXosVuHK7NyMwmyLEth2CCsTApTZ1Ka9FCFS1 1iuONYcpnqjDrUJYgiHirSxQ/ZoqEiyEkIJHLVnlBZuUoChNMtHqghFzd2lyfj2a/av/ rk7ufcmQNtFSLIfSuiJTFtl71qHo5e2x2ZUjJWgxKTPtsSYgw+2RgdeDQNme9KIhuqVJ vOgY5wMBMAHZJOIp0HG97PhSWGeIXU5Frm9TFIxKoe8GM/bam7fti+QBJR7b8vYIYKZl CMrw== X-Gm-Message-State: AOAM531bQn+6WePjL86v9N5HlOYDdm6WwUnj6k3y6qxnFmPEF361qqc7 G+OhflwXKbhfcQHZfUpU/cqcgSxmG9yC5l9ecyY= X-Google-Smtp-Source: ABdhPJwPHsjy4b0CxrMUIAedHBz585NlO4zoEO2ibf63ofRIbtuXkT6UOzjKJ0hbRhxJiORdRrLRPE9oSBbU93TEFgI= X-Received: by 2002:a05:6602:2e91:: with SMTP id m17mr173670iow.96.1644951041791; Tue, 15 Feb 2022 10:50:41 -0800 (PST) MIME-Version: 1.0 References: <164461032874.9678.9708057254834166884@wrigleys.postgresql.org> In-Reply-To: From: Troy Frericks Date: Tue, 15 Feb 2022 12:50:05 -0600 Message-ID: Subject: Re: Data Type Size Calculation To: Bruce Momjian Cc: troy@frericks.us, pgsql-docs@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000084dbc205d8130250" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000084dbc205d8130250 Content-Type: text/plain; charset="UTF-8" For now, yes... I'm suggesting that the documentation be completed by adding a few sentences few extra sentences. Troy. # On Mon, Feb 14, 2022, 12:51 Bruce Momjian wrote: > On Fri, Feb 11, 2022 at 08:12:08PM +0000, PG Doc comments form wrote: > > The following documentation comment has been logged on the website: > > > > Page: https://www.postgresql.org/docs/13/datatype-numeric.html > > Description: > > > > > The actual storage requirement is two bytes for each group of four > decimal > > digits, plus three to eight bytes overhead. > > > > Please describe what 'overhead' means. > > > > I'd like to be able to calculate the data size of NUMBER(19,4). I can > > calculate 2 bytes per 4 digits... with 19 digits, I have 5 groups of 4 > > digits, > > > > so the data length I seek is 5 bytes + overhead... then I'm left hanging. > > :( > > Well, you can create it and then call pg_column_size(): > > CREATE TABLE test (x NUMERIC(19,4)); > > SELECT pg_column_size('test.x'); > pg_column_size > ---------------- > 7 > > If you want more details, you will need to look at the source code. > > -- > Bruce Momjian https://momjian.us > EDB https://enterprisedb.com > > If only the physical world exists, free will is an illusion. > > --00000000000084dbc205d8130250 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
For now, yes... I'm suggesting = that the documentation be completed by adding a few sentences few extra sen= tences.
Troy.
#


On Mon, Feb 14, = 2022, 12:51 Bruce Momjian <bruce@momjian.us> wrote:
On Fri, Feb 11, 2022 at 08:12:08PM +0000, PG Doc comments form wrote:=
> The following documentation comment has been logged on the website: >
> Page: https://www.postgresql= .org/docs/13/datatype-numeric.html
> Description:
>
> > The actual storage requirement is two bytes for each group of fou= r decimal
> digits, plus three to eight bytes overhead.
>
> Please describe what 'overhead' means.
>
> I'd like to be able to calculate the data size of NUMBER(19,4). I = can
> calculate 2 bytes per 4 digits... with 19 digits, I have 5 groups of 4=
> digits,
>
> so the data length I seek is 5 bytes + overhead... then I'm left h= anging.
> :(

Well, you can create it and then call pg_column_size():

=C2=A0 =C2=A0 =C2=A0 =C2=A0 CREATE TABLE test (x NUMERIC(19,4));

=C2=A0 =C2=A0 =C2=A0 =C2=A0 SELECT pg_column_size('test.x');
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pg_column_size
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ----------------
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 7

If you want more details, you will need to look at the source code.

--
=C2=A0 Bruce Momjian=C2=A0 <bruce@momjian.us>=C2=A0 =C2=A0 =C2=A0 = =C2=A0 https://momjian.us
=C2=A0 EDB=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 https://enterprisedb.com

=C2=A0 If only the physical world exists, free will is an illusion.

--00000000000084dbc205d8130250--