Optimizing bulk update performance - Mailing list pgsql-general

From Yang Zhang
Subject Optimizing bulk update performance
Date
Msg-id CAKxBDU-bUFVvmx_MzruQfObvnTz_XXB-R==r_PfB=JmjX8KGng@mail.gmail.com
Whole thread Raw
Responses Re: Optimizing bulk update performance
Re: Optimizing bulk update performance
List pgsql-general
It currently takes up to 24h for us to run a large set of UPDATE
statements on a database, which are of the form:

    UPDATE table SET field1 = constant1, field2 = constant2, ...  WHERE
    id = constid

(We're just overwriting fields of objects identified by ID.)

The tables have handfuls of indices each and no foreign key constraints.
No COMMIT is made till the end.

It takes 2h to import a `pg_dump` of the entire DB.  This seems like a
baseline we should reasonably target.

Short of producing a custom program that somehow reconstructs a dataset
for Postgresql to re-import, is there anything we can do to bring the
bulk UPDATE performance closer to that of the import?  (This is an area
that we believe log-structured merge trees handle well, but we're
wondering if there's anything we can do within Postgresql.)

Some ideas:

- dropping all non-ID indices and rebuilding afterward?
- increasing checkpoint_segments, but does this actually help sustained
  long-term throughput?
- using the techniques mentioned here?  (Load new data as table, then
  "merge in" old data where ID is not found in new data)
  <http://www.postgresql.org/message-id/3a0028490809301807j59498370m1442d8f5867e9668@mail.gmail.com>

Basically there's a bunch of things to try and we're not sure what the
most effective are or if we're overlooking other things.  We'll be
spending the next few days experimenting, but we thought we'd ask here
as well.

Thanks.


pgsql-general by date:

Previous
From: Rafał Pietrak
Date:
Subject: Re: is there a way to deliver an array over column from a query window?
Next
From: Gavin Flower
Date:
Subject: Re: Optimizing bulk update performance