Re: Adding a non-null column without noticeable downtime - Mailing list pgsql-general

From Sameer Kumar
Subject Re: Adding a non-null column without noticeable downtime
Date
Msg-id CADp-Sm5S6nUQBoPEqDRjp6RSBTMfOGg93QXL9XLUk+yEfXyhGA@mail.gmail.com
Whole thread Raw
In response to Adding a non-null column without noticeable downtime  (Zev Benjamin <zev-pgsql@strangersgate.com>)
Responses Re: Adding a non-null column without noticeable downtime  (Zev Benjamin <zev-pgsql@strangersgate.com>)
List pgsql-general
I think index should help.
Why don't you try it out and check the explain plan of it?
If you are planning to break it down as below:
1. ALTER TABLE "foo" ADD COLUMN "bar" boolean;
2. UPDATE foo SET bar = False; -- Done in batches
3. ALTER TABLE "foo" ALTER COLUMN "bar" SET DEFAULT False;
4. ALTER TABLE "foo" ALTER COLUMN "bar" SET NOT NULL;


I would suggest on interchanging operation 2 and 3 in sequence

pgsql-general by date:

Previous
From: Zev Benjamin
Date:
Subject: Re: Adding a non-null column without noticeable downtime
Next
From: john gale
Date:
Subject: cannot delete corrupted rows after DB corruption: tuple concurrently updated