pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Ron <ronljohnsonjr@gmail.com>
Cc: 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 11:26:39 -0400
Message-ID: <3421791.1659021999@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZ8su=VAeyNZ6Wj5cU1OoZLQB+B3iPWh49k2yjk4o4ujQ@mail.gmail.com>
References: <a4465ae0-574a-1727-fcdd-1dac49b874c0@gmail.com>
	<CAKFQuwZ8su=VAeyNZ6Wj5cU1OoZLQB+B3iPWh49k2yjk4o4ujQ@mail.gmail.com>

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

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <3421791.1659021999@sss.pgh.pa.us>
Permalink:  ../3421791.1659021999@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3421791.1659021999@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, 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: <3421791.1659021999@sss.pgh.pa.us>

* 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