From: Bruce Momjian <bruce@momjian.us>
To: James Healy <james@yob.id.au>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Gradual migration from integer to bigint?
Date: Sat, 30 Sep 2023 13:35:02 -0400
Message-ID: <ZRhcRnnUrGsB3p7K@momjian.us> (raw)
In-Reply-To: <CAE4DO2THV1_70g5nRWDZiJOHPP7LnSHfYGzAdiTzFiu4L+o5iA@mail.gmail.com>
References: <CAE4DO2THV1_70g5nRWDZiJOHPP7LnSHfYGzAdiTzFiu4L+o5iA@mail.gmail.com>
On Sat, Sep 30, 2023 at 03:55:20PM +1000, James Healy wrote:
> My organization has a number of very large tables (most 100s of GB, a
> couple over a Tb) that were created many years ago by a tool that
> defaulted to integer PKs rather than bigint. Those PKs have a number
> of integer FKs in related tables as well. We shouldn't have let them
> get so big, but that's a conversation for another day.
>
> Some are approaching overflow and we're slowly doing the work to
> migrate to bigint. Mostly via the well understood "add a new id_bigint
> column, populate on new tuples, backfill the old, switch the PK"
> method. The backfill is slow on these large tables, but it works and
> there's plenty of blog posts and documentation to follow.
>
> It did make me curious though: would it be possible for postgres to
> support gradual migration from integer to bigint in a more transparent
> way, where new and updated tuples are written as bigint, but existing
> tuples can be read as integer?
>
> I assume maybe a complication is that the catalog says the column is
> either 32bit int or 64bit bigint and making that conditional is hard.
> There's presumably other considerations I'm unaware of too. My core
> question: are there significant technical blockers to supporting this
> kind of gradual in place migration, or has it just not been enough of
> a problem that it's received attention?
I think this talk will help you:
https://www.youtube.com/watch?v=XYRgTazYuZ4
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Only you can decide what is important to you.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: bruce@momjian.us, james@yob.id.au
Subject: Re: Gradual migration from integer to bigint?
In-Reply-To: <ZRhcRnnUrGsB3p7K@momjian.us>
References: <CAE4DO2THV1_70g5nRWDZiJOHPP7LnSHfYGzAdiTzFiu4L+o5iA@mail.gmail.com> <ZRhcRnnUrGsB3p7K@momjian.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