Re: feature request - adding columns with default value

From: Andrew Sullivan <andrew(at)libertyrms(dot)info>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: feature request - adding columns with default value
Date: 2003-04-04 12:13:34
Message-ID: 20030404121334.GB20972@libertyrms.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Apr 04, 2003 at 10:08:50AM +0200, Henrik Steffen wrote:
> it takes about 10 minutes to perform this update, and for about 6 minutes
> all other updates to the table are in status "waiting", this leads to
> a very high load and all max_connection setting is reached soon
> (on a Dual-Xeon 2.4 GHz machine with 2 GB RAM)
>
> i would suggest to change the "alter table add column" function to
> adding a default value while adding the column if this is possible
> and if this minimizes "down-time".

Why do you think that having the back end set the default value on
those other rows won't sugger the very same problem? What esle is it
to do except implicitly iees the same UPDATE you do?

One way around this problem is to write a little script (I use perl
for this, but pick your favourite flavour) which does the updates
1000 at a time. This minimises the locking, so you don't have to
have anything WAITING for 10 minutes.

It also allows you to insert the occasional VACUUM so that your FSM
settings don't have to be huge.

A

--
----
Andrew Sullivan 204-4141 Yonge Street
Liberty RMS Toronto, Ontario Canada
<andrew(at)libertyrms(dot)info> M2P 2A8
+1 416 646 3304 x110

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mlw 2003-04-04 12:21:49 Re: [HACKERS] OSS database needed for testing
Previous Message Richard Huxton 2003-04-04 11:32:34 Re: Problem with odbc.sql