Re: Why does increasing the precision of a numeric column rewrites the table?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why does increasing the precision of a numeric column rewrites the table?
Date: 2017-10-11 14:30:21
Message-ID: 8130.1507732221@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
> I don't understand why going from numeric(12,2) to numeric(15,3) would require a table rewrite.

The comment for numeric_transform explains this:

* Flatten calls to numeric's length coercion function that solely represent
* increases in allowable precision. Scale changes mutate every datum, so
* they are unoptimizable. Some values, e.g. 1E-1001, can only fit into an
* unconstrained numeric, so a change from an unconstrained numeric to any
* constrained numeric is also unoptimizable.

The issue is basically that changing '1.00' to '1.000' requires a change
in the actually-stored value.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message rverghese 2017-10-11 18:18:38 Making subscribers read only in Postgres 10 logical replication
Previous Message Pavel Stehule 2017-10-11 14:11:23 Re: BUG #14850: Implement optinal additinal parameter for 'justify' date/time function