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 1nJgRM-0006JI-AJ for pgsql-docs@arkaria.postgresql.org; Mon, 14 Feb 2022 18:51:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJgRL-0002nA-0K for pgsql-docs@arkaria.postgresql.org; Mon, 14 Feb 2022 18:51:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJgRK-0002n0-PV for pgsql-docs@lists.postgresql.org; Mon, 14 Feb 2022 18:51:10 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJgRI-0004JL-2w for pgsql-docs@lists.postgresql.org; Mon, 14 Feb 2022 18:51:10 +0000 Received: from bruce by momjian.us with local (Exim 4.94.2) (envelope-from ) id 1nJgRF-00Grh8-IP; Mon, 14 Feb 2022 13:51:05 -0500 Date: Mon, 14 Feb 2022 13:51:05 -0500 From: Bruce Momjian To: troy@frericks.us, pgsql-docs@lists.postgresql.org Subject: Re: Data Type Size Calculation Message-ID: References: <164461032874.9678.9708057254834166884@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <164461032874.9678.9708057254834166884@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.