Re: add column with default value is very slow

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "AI Rumman *EXTERN*" <rummandba(at)gmail(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: add column with default value is very slow
Date: 2012-09-11 13:41:04
Message-ID: D960CB61B694CF459DCFB4B0128514C2086255D3@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

AI Rumman wrote:
> I execued the query:
> ALTER TABLE entity ADD COLUMN owner_type char(1) NOT NULL default 'U';
>
> The db is stuck. The enity table has 2064740 records;
>
> Watching locks:
[all locks are granted]

> Any idea for the db stuck?

To add the column, PostgreSQL has to modify all rows in the table.

But then 2064740 records is not very much, so it shouldn't take forever.

Do you see processor or I/O activity?

Yours,
Laurenz Albe

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message hubert depesz lubaczewski 2012-09-11 13:44:25 Re: add column with default value is very slow
Previous Message AI Rumman 2012-09-11 13:20:28 add column with default value is very slow