Re: Data Type Size Calculation

From: Troy Frericks <troy(dot)frericks(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: troy(at)frericks(dot)us, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Data Type Size Calculation
Date: 2022-02-15 18:50:05
Message-ID: CAPpwsZzAS6XRLjcH0G9w9NgHekvDXxRH_A2pCiQGOgUJmokW7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

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 <bruce(at)momjian(dot)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 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 <bruce(at)momjian(dot)us> https://momjian.us
> EDB https://enterprisedb.com
>
> If only the physical world exists, free will is an illusion.
>
>

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Swaha Miller 2022-02-15 21:39:29 Re: Question about role attributes docs
Previous Message PG Doc comments form 2022-02-15 16:17:53 Does the POSITION() function takes into account the COLLATION... or not ?!?