Re: Updating a very large table - Mailing list pgsql-admin

From Kevin Grittner
Subject Re: Updating a very large table
Date
Msg-id 49F1D408.EE98.0025.0@wicourts.gov
Whole thread Raw
In response to Re: Updating a very large table  (Chris Browne <cbbrowne@acm.org>)
Responses Re: Updating a very large table
List pgsql-admin
Chris Browne <cbbrowne@acm.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

pgsql-admin by date:

Previous
From: Chris Browne
Date:
Subject: Re: Updating a very large table
Next
From: Félix Sánchez Rodríguez
Date:
Subject: Deleting "parent" record