Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBQlT-0004DC-LI for pgsql-performance@postgresql.org; Tue, 11 Sep 2012 13:44:31 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TBQlQ-00007A-Fh for pgsql-performance@postgresql.org; Tue, 11 Sep 2012 13:44:31 +0000 Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.80) (envelope-from ) id 1TBQlO-0007lk-1t; Tue, 11 Sep 2012 15:44:26 +0200 Date: Tue, 11 Sep 2012 15:44:25 +0200 From: hubert depesz lubaczewski To: AI Rumman Cc: pgsql-performance@postgresql.org Subject: Re: add column with default value is very slow Message-ID: <20120911134425.GA27828@depesz.com> Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -0.8 (/) X-Archive-Number: 201209/39 X-Sequence-Number: 47785 On Tue, Sep 11, 2012 at 07:20:28PM +0600, AI Rumman wrote: > I have a table as follows: > 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; such alter table has to rewrite whole table. So it will take a while > Watching locks: output of this was perfectly unreadable, because your email client wrapped lines at some random places. In future - please put such dumps on some paste site, or just attach it to mail, and not copy/paste them to body of message. Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/