NUMERIC size

Lists: pgsql-docs
From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: pgsql-docs <pgsql-docs(at)postgresql(dot)org>
Subject: NUMERIC size
Date: 2012-03-22 02:35:40
Message-ID: CAHGQGwGupGaNmQQHHhm783j9vMiNYtPFZaE0eKwsCLGwMU2x+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs

Hi,

> Numeric values are physically stored without any extra leading or
> trailing zeroes. Thus, the declared precision and scale of a column
> are maximums, not fixed allocations. (In this sense the numeric type
> is more akin to varchar(n) than to char(n).) The actual storage
> requirement is two bytes for each group of four decimal digits,
> plus five to eight bytes overhead.

The last sentence of the above seems not to be correct. Because,
thanks to the reduction of NUMERIC size (committed in 9.1), its header
size is three, five or eight for now. Attached patch fixes this.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
numeric_typo.patch text/x-diff 517 bytes

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: pgsql-docs <pgsql-docs(at)postgresql(dot)org>
Subject: Re: NUMERIC size
Date: 2012-03-22 19:41:24
Message-ID: CA+TgmoZcNyWUBFVUUAGostd-EPsfecdVHY1F+ZRxziOuwfFO7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs

On Wed, Mar 21, 2012 at 10:35 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>> Numeric values are physically stored without any extra leading or
>> trailing zeroes. Thus, the declared precision and scale of a column
>> are maximums, not fixed allocations. (In this sense the numeric type
>> is more akin to varchar(n) than to char(n).) The actual storage
>> requirement is two bytes for each group of four decimal digits,
>> plus five to eight bytes overhead.
>
> The last sentence of the above seems not to be correct. Because,
> thanks to the reduction of NUMERIC size (committed in 9.1), its header
> size is three, five or eight for now. Attached patch fixes this.

Nice catch. Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company