Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why? - Mailing list pgsql-general

From Tom Lane
Subject Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?
Date
Msg-id 329227.1762187472@sss.pgh.pa.us
Whole thread Raw
In response to Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?  (Marcelo Fernandes <marcefern7@gmail.com>)
List pgsql-general
Marcelo Fernandes <marcefern7@gmail.com> writes:
> After doing some playing around with different operations against a numeric
> column, namely: increasing/decreasing the precision or increasing/decreasing
> the scale, I noticed that the table is rewritten in all cases except when
> increasing the precision number.

Yup.

> For example, is there a catalog table I can have a look to see how these values
> are defined, along with some form of documentation to understand how they are
> interpreted by Postgres?

You'd have to look into the source code:

https://github.com/postgres/postgres/blob/c4067383cb2c155c4cfea2351036709e2ebb3535/src/backend/utils/adt/numeric.c

The first few hundred lines of numeric.c are largely comments that
you'd find relevant.  Also see numeric_support():


https://github.com/postgres/postgres/blob/c4067383cb2c155c4cfea2351036709e2ebb3535/src/backend/utils/adt/numeric.c#L1179

ALTER TABLE skips table rewrite if the datatype conversion expression
is simplified to a no-op by a support function such as
numeric_support.

            regards, tom lane



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Enquiry about TDE with PgSQL
Next
From: Bruce Momjian
Date:
Subject: Re: Enquiry about TDE with PgSQL