Re: alter table is taking a long time

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: alter table is taking a long time
Date: 2009-11-07 14:33:08
Message-ID: 20091107143307.GY5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Nov 07, 2009 at 10:48:14AM +0200, Johan Nel wrote:
> update pg_attribute set attlen = 4 + <newlength>
> where attname = 'yourcolumnname'
>
> That will take only a couple of milliseconds to do.

It will also update *every* column with that name. Something involving
the "attrelid" would be much safer. I'd use something like:

update pg_attribute set attlen = 4 + <newlength>
where attrelid = regclass 'your table name'
and attname = 'yourcolumnname';

--
Sam http://samason.me.uk/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-11-07 15:21:14 Re: WAL shipping to two machines (PITR)
Previous Message Geoffrey 2009-11-07 13:58:07 Re: WAL shipping to two machines (PITR)