How to efficiently update many records at once - Mailing list pgsql-general

From Martin Weinberg
Subject How to efficiently update many records at once
Date
Msg-id 199911182007.PAA18109@osprey.astro.umass.edu
Whole thread Raw
Responses Re: [GENERAL] How to efficiently update many records at once  (Beth Strohmayer <strohmayer@itd.nrl.navy.mil>)
List pgsql-general
I have two tables with different information indexed by a unique key.
I want to update the contents of one table if an entry exists in
a second table.

Some playing with explain suggests that the optimum strategy using
UPDATE is:

update table1 set x=1 from table2 where key in
    (select key from table2 where table1.key=table2.key);

This *does work* but can double the size of the database (until
the next vacuum).  Is there an efficient way to do this in situ?

The problem is that my database is 100GB and only have 132GB
of space.

Sorry if this is a SQL/DBMS FAQ . . . I couldn't find any guidance
in the books and newsgroups.

--Martin

===========================================================================

Martin Weinberg                      Phone: (413) 545-3821
Dept. of Physics and Astronomy       FAX:   (413) 545-2117/0648
530 Graduate Research Tower
University of Massachusetts
Amherst, MA  01003-4525



pgsql-general by date:

Previous
From: Miguel Montes
Date:
Subject: Problems with datetime
Next
From: Faqir Abu Tahir
Date:
Subject: