public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Marcelo Fernandes <[email protected]>
Cc: [email protected]
Subject: Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?
Date: Mon, 03 Nov 2025 11:31:12 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAM2F1VNniBN2RK9+DD8Pwz4tphE-1w3hZgtwZF-6c08--6JLiw@mail.gmail.com>
References: <CAM2F1VNniBN2RK9+DD8Pwz4tphE-1w3hZgtwZF-6c08--6JLiw@mail.gmail.com>

Marcelo Fernandes <[email protected]> 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...

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...

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






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox