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

From Zev Benjamin
Subject Re: Adding a non-null column without noticeable downtime
Date
Msg-id 530CF317.8050804@strangersgate.com
Whole thread Raw
In response to Re: Adding a non-null column without noticeable downtime  (Sameer Kumar <sameer.kumar@ashnik.com>)
List pgsql-general
EXPLAIN does not appear to work on ALTER TABLE statements:

=> EXPLAIN ALTER TABLE "foo" ALTER COLUMN "bar" SET NOT NULL;
ERROR:  syntax error at or near "ALTER"
LINE 1: explain ALTER TABLE "foo" ALTER COLUMN "bar" SET NOT NULL;
                 ^


Zev

On 02/25/2014 01:56 PM, Sameer Kumar wrote:
> 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: john gale
Date:
Subject: cannot delete corrupted rows after DB corruption: tuple concurrently updated
Next
From: Eliot Gable
Date:
Subject: Re: JSON vs Text + Regexp Index Searching