Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?

From: "Weck, Luis" <luis(dot)weck(at)pismo(dot)io>
To: Marcelo Fernandes <marcefern7(at)gmail(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?
Date: 2025-11-03 11:35:39
Message-ID: IA3PR10MB8113ACB1FED522A1EC00FAF28DC7A@IA3PR10MB8113.namprd10.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

My understanding is that Postgres can guarantee that all the values in the table will fit the new precision without having to check. If you change the scale, it might be the case that some values won’t fit anymore, and Postgres must return an error. Numeric by itself is a variable length type, like TEXT (in a sense). That’s why we can modify its size without requiring a table rewrite at all!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2025-11-03 15:08:15 Re: Enquiry about TDE with PgSQL
Previous Message Weck, Luis 2025-11-03 11:32:37 Re: Increasing a NUMERIC column precision doesn't cause a table rewrite. Why?