Re: How to add columns faster - Mailing list pgsql-general

From Christophe Pettus
Subject Re: How to add columns faster
Date
Msg-id 1C6E9170-65F0-4F16-85E1-97C422699702@thebuild.com
Whole thread Raw
In response to Re: How to add columns faster  (yudhi s <learnerdatabase99@gmail.com>)
Responses Re: How to add columns faster
List pgsql-general

> On Mar 3, 2024, at 11:40, yudhi s <learnerdatabase99@gmail.com> wrote:
> Thanks for the clarification. In case of adding the column as volatile default (like current_timestamp function as
default)or say adding NOT NULL column with some conditional population of existing values will be a full table rewrite.
Insuch scenarios, the full table rewrite operation is going to take a long time , so what will be the fastest way to
achievethat with minimal to no downtime?  

For other situations, you probably have to create the column as NULL-able, and then backfill it in groups of records
untilthe whole column is populated.  Remember that dropping the NULL constraint afterwards will require a full table
read(although not a rewrite). 


pgsql-general by date:

Previous
From: yudhi s
Date:
Subject: Re: How to add columns faster
Next
From: Christophe Pettus
Date:
Subject: Re: How to add columns faster