Re: Updating a very large table

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Chris Browne" <cbbrowne(at)acm(dot)org>,<pgsql-admin(at)postgresql(dot)org>
Subject: Re: Updating a very large table
Date: 2009-04-24 20:00:24
Message-ID: 49F1D408.EE98.0025.0@wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Chris Browne <cbbrowne(at)acm(dot)org> wrote:

> I'd suggest adding an index

The OP said the table had 15 indexes already. I would guess one of
those could be used. Perhaps it has a primary key....

> update table1 set new_column = [whatever calculation]
> where new_column is null and
> quasi_unique_column in
> (select quasi_unique_column from table1
> where new_column is null limit 1000);

Or, if the primary key (or other unique or quasi-unique existing
index) has multiple columns, this could still be done with:

update table1 set new_column = [whatever calculation]
where new_column is null and
(col1, col2) in
(select col1, col2 from table1
where new_column is null limit 1000);

-Kevin

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Ries van Twisk 2009-04-24 21:12:00 Re: Deleting "parent" record
Previous Message Chris Browne 2009-04-24 15:51:55 Re: Updating a very large table