Re: Switching Primary Keys to BigInt - Mailing list pgsql-general

From Mohamed Wael Khobalatte
Subject Re: Switching Primary Keys to BigInt
Date
Msg-id CABZeWdxCGX-WsrV+Cbz5f4L5UqxFoa_agKzCOrP5=6otpCEDZA@mail.gmail.com
Whole thread Raw
In response to Re: Switching Primary Keys to BigInt  ("Daniel Verite" <daniel@manitou-mail.org>)
Responses Re: Switching Primary Keys to BigInt
List pgsql-general


On Wed, Jul 22, 2020 at 11:13 AM Daniel Verite <daniel@manitou-mail.org> wrote:
        Mohamed Wael Khobalatte wrote:

> We lock the table as a precaution, with the understanding that we are
> undergoing a "small" downtime to finish replacing the int id by the new
> bigint

Ah, sorry I overlooked that most row updates are done
pre-transaction in a preliminary step:
  /* in batches, we update all the rows to new_id = id */

No worries. I suppose the answer to the original question, which is how to avoid a table scan when adding a primary key constraint to a newly backfilled column is "there is no way"? Downtime might be at least as long as the table scan.

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Transaction control in SECURITY DEFINER procedures
Next
From: Bruce Momjian
Date:
Subject: Re: Doubt in mvcc