pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: What to watch out for when ALTERing NUMERIC(38,0) to BIGINT?
Date: Thu, 28 Jul 2022 12:41:41 -0500
Message-ID: <5a747f00-02dc-3922-6506-fef8ccd701bf@gmail.com> (raw)
In-Reply-To: <3421791.1659021999@sss.pgh.pa.us>
References: <a4465ae0-574a-1727-fcdd-1dac49b874c0@gmail.com>
	<CAKFQuwZ8su=VAeyNZ6Wj5cU1OoZLQB+B3iPWh49k2yjk4o4ujQ@mail.gmail.com>
	<3421791.1659021999@sss.pgh.pa.us>

On 7/28/22 10:26, Tom Lane wrote:
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
>> On Thu, Jul 28, 2022 at 8:13 AM Ron <ronljohnsonjr@gmail.com> wrote:
>>> Besides what's mentioned in
>>> https://www.postgresql.org/docs/12/ddl-alter.html#id-1.5.4.8.10, what
>>> happens *internally* when I run:
>>> ALTER TABLE foo ALTER COLUMN bar TYPE BIGINT;
>> IIUC, that would be the silver lining in all of this - the rewritten table
>> would have zero fragmentation and bloat.
> Yeah.  What happens internally is a table rewrite: the entire content
> of the table (and its indexes) is written into a new set of files.
> At commit, the old files are deleted.  The main gotchas, for a large
> table, are the transient disk space consumption and the fact that the
> table stays exclusively locked the whole time.

Rewriting a 3TB table doesn't seem appetizing.  Fortunately, there's only 
one table like that...

-- 
Angular momentum makes the world go 'round.





view thread (4+ messages)

Message-ID: <5a747f00-02dc-3922-6506-fef8ccd701bf@gmail.com>
Permalink:  ../5a747f00-02dc-3922-6506-fef8ccd701bf@gmail.com/
Also on:    postgresql.org/message-id/5a747f00-02dc-3922-6506-fef8ccd701bf@gmail.com

 · 

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: pgsql-admin@postgresql.org
  Cc: ronljohnsonjr@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: What to watch out for when ALTERing NUMERIC(38,0) to BIGINT?
  In-Reply-To: <5a747f00-02dc-3922-6506-fef8ccd701bf@gmail.com>

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

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