Re: alter table is taking a long time

From: Johan Nel <johan(dot)nel(at)xsinet(dot)co(dot)za>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: alter table is taking a long time
Date: 2009-11-07 08:48:14
Message-ID: hd3c90$fn7$1@news.eternal-september.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

stanciutheone(at)gmail(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2009-11-07 13:10:23 WAL shipping to two machines (PITR)
Previous Message stanciutheone@gmail.com 2009-11-07 08:18:42 Re: alter table is taking a long time