Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4fkw-002R0q-1T for pgsql-admin@arkaria.postgresql.org; Mon, 23 Mar 2026 13:55:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4fku-000Nzt-23 for pgsql-admin@arkaria.postgresql.org; Mon, 23 Mar 2026 13:55:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4fku-000Nzl-0s for pgsql-admin@lists.postgresql.org; Mon, 23 Mar 2026 13:55:44 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4fkt-00000000dHh-015K for pgsql-admin@lists.postgresql.org; Mon, 23 Mar 2026 13:55:43 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-439b94a19fdso2668612f8f.0 for ; Mon, 23 Mar 2026 06:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1774274141; x=1774878941; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=H8oknldNu8YqseT8r00waFpp62GROcA5L6wvN/kcQ9M=; b=NRIKvRn9OwL+inVPUC6jzlCwABa5io7NrCnbUcBa1+LFzma1WysK6bw2Z8gtJLaLlO ZxJ25s0YgwWVHIA77bPNZul+EbnYYTplHMbRPzhnK5mufWNwF6WsUApc6fJcm+8uLZCv jD9AsuXhTrHLir978IqOKADx8T0J+VlwV23ZLcs8umxcX/Ah/inf2vtrsOKBGZheP+H1 aIokZJGW84oc2SK4Iuxy7Ujzjg6hsKzQFUrRhGbSIAq9R/aGDWvo0qC65XvJPFxlXMQ5 zwxV0XBTejtD0ct7/FrrDoD3Ros/zUKE9wr1SkNMTX1kQdgMI2QrYUERvXmcXzcGJkt3 g4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774274141; x=1774878941; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H8oknldNu8YqseT8r00waFpp62GROcA5L6wvN/kcQ9M=; b=UpOaXuiVm4zEkR2/DlbexDRj8Bg6a3/k03yWHHogYDSdNd9S8Zs3aUGqCsLGAQMO1D ISizjBp4xy/v8JQLgtBihzm/DcnyKNlBmDB/looDo4VwA3Scwx80fflkepMLi5kj28dA 7/qF6r4e9T2crSGFcR6+grVIyYRyUkmEJTE57r3A7JYIVCflVGQU73/cSaIxs/v+taYZ Np8bR41a2+LSWTV776eoZ7VaS7Ks7Pspvc+Bn8u8VrGX1hnYmxdeSxjGk9L6qWS7zvQE mYP/F7JnkMdTyPaAutjLWSz2Ck+F3zh/LUYdpjuTBJj/4E7qYWO/rP7FE1CLPXrrKAla vluQ== X-Forwarded-Encrypted: i=1; AJvYcCWf4UelUwRF6NwOxUfNvrfEE8lHdNTp/O97zg/a8QRdPyGnP0GDy/NStnqQLt0KUwDiEtLKTf+skxwN4g==@lists.postgresql.org X-Gm-Message-State: AOJu0YxmLBAdvIFoiE3f8hwrxACrgrc0ZLbFt82l42ZAyKMlApUzgYnh Pq9mYZ+NAdG819VCMQ3b0S0KJj2UuZIgdwQbUroRKd2Ie52dFZwxemh160aVsE7nH1w= X-Gm-Gg: ATEYQzxfgY7xNO0qN1Ew+BHKpENB1qZc1zDDtisGfQMkHZDIQqwEmVKYH9EZm0/k7yI MMSRg6d6iPhEpkERFDBNmqmz9BY543Bs+6Zu9Nu24+DLlCJMvPVjcUQ7dpEpd1fqIc6QLDgVPJv wU4cvVRf3Civd/OWsGUjnDcm/FDSO5ww+Xgrg1lzMIDzRyXYvS+hSohqtTZQBqt2oSMbHTxkSB+ exvZz/VMozeu6a15tuBNMhm8GjGTgtjB/J+khrtD4Hh4fxkF+zgTVwadNpzUZzxwpragYpeceOk 61A41wgflWmd9OL2zY+TJo8nfHzm+zbmlAQF7NcsI6oGJTmV+kDPWxPuvRy/353kwGAo6vT7ZyW bBN9QGfzicq52ID39WYz+r7ISsja37+GWti9gESDGg5DwUqsD/Gc+LjL6qcqpYQckn3Jc8B7rLG bulhz6yVIkqiAE5pN4WUDw/sB0l/h+P0kqfQrAzEdg6P0rh+NfmQQb0w== X-Received: by 2002:a05:6000:401e:b0:43b:3bed:1548 with SMTP id ffacd0b85a97d-43b64270cb6mr19020673f8f.42.1774274141357; Mon, 23 Mar 2026 06:55:41 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:809b:1e6a:2037:fdcf:bd81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b646b0b0csm28370344f8f.15.2026.03.23.06.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 06:55:41 -0700 (PDT) Message-ID: <24bc88e97f83e7d0cca8b51c5689daccf01cefa1.camel@cybertec.at> Subject: Re: Technical validation on altering atttypmod for numeric column in PostgreSQL From: Laurenz Albe To: Mauricio Martini , "pgsql-admin@lists.postgresql.org" Date: Mon, 23 Mar 2026 14:55:40 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-03-23 at 13:02 +0000, Mauricio Martini wrote: > I am evaluating an approach to change the scale of a numeric=C2=A0column = from numeric(18,2) > to numeric(18,4)=C2=A0in a large table, aiming to avoid the cost of a ful= l table rewrite. > > The proposed approach involves directly updating the PostgreSQL system ca= talog: > > UPDATE pg_attribute SET atttypmod =3D (18 << 16 | 4) + 4 WHERE attrelid = =3D 'table'::regclass > =C2=A0AND attname =C2=A0=3D 'column'; > > Before considering this in practice, I would like to validate a few point= s: > =C2=A0* Is this approach considered safe from a data integrity perspectiv= e? > =C2=A0* Is there a risk of inconsistencies in the internal representation= of the numeric > =C2=A0type (especially regarding scale)? > =C2=A0* Could this impact indexes, functions, or aggregation operations? > =C2=A0* Is there any official recommendation or prior experience using th= is approach in > production environments? > =C2=A0* Are there additional risks related to rollback, maintenance, or f= uture operations > (e.g., dump/restore, upgrades)? > > The goal is to determine whether this alternative is viable, or if we sho= uld stick with more > standard approaches (e.g., shadow column, incremental migration, etc.). > If anyone has experience with a similar scenario, your insights would be = appreciated. It should be safe to perform this catalog modification, but I won't take an= y liability. "If it breaks, you get to keep both pieces." Two things come to my mind when considering such a dangerous activity: - LOCK the table in ACCESS EXCLUSIVE node while you perform the operation - make sure there is no view that depends on the column, or if there is, drop the view first and re-create it afterwards I myself would be a tad afraid to perform something like that. Test well. Yours, Laurenz Albe