Re: alter table is taking a long time - Mailing list pgsql-general

From Johan Nel
Subject Re: alter table is taking a long time
Date
Msg-id hd3c90$fn7$1@news.eternal-september.org
Whole thread Raw
In response to Re: alter table is taking a long time  ("stanciutheone@gmail.com" <stanciutheone@gmail.com>)
Responses Re: alter table is taking a long time  (Sam Mason <sam@samason.me.uk>)
List pgsql-general
Hi,

stanciutheone@gmail.com wrote:
> is just a varchar field that i want to make it bigge ,right now the
> alter table is working for over 6 hours

You can try to update the pg_attribute table directly.  Just first do some
select statements to ensure you only update what you really want to.

Also, make a backup before you do it.

update pg_attribute set attlen = 4 + <newlength>
where attname = 'yourcolumnname'

That will take only a couple of milliseconds to do.

I used this before in scenarios where the column to be changed was
referenced in many queries making it almost impossible to do a drop and
recreating of the queries without any side effects.

HTH,

Johan Nel
Pretoria, South Africa.

pgsql-general by date:

Previous
From: "Michael Harris"
Date:
Subject: Re: alter table is taking a long time
Next
From: "stanciutheone@gmail.com"
Date:
Subject: Re: alter table is taking a long time