From: Scott Marlowe <scott.marlowe@gmail.com>
To: Mark Steben <msteben@autorevenue.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Mass updates on a large table
Date: Fri, 10 Aug 2007 12:57:53 -0500
Message-ID: <dcc563d10708101057l7dd53571w39a333988a12c84@mail.gmail.com> (raw)
In-Reply-To: <009601c7db75$12876c30$b501a8c0@D1RPQZB1>
References: <009601c7db75$12876c30$b501a8c0@D1RPQZB1>
On 8/10/07, Mark Steben <msteben@autorevenue.com> wrote:
>
> Good afternoon,
>
> I am attempting an update on two new date field columns on a 17 million row
> table. Every row gets updated.
>
> The update statement is a simple one:
>
> UPDATE EMAILRCPTS SET ID = ID
>
> And the update of the new date fields themselves occurs as the result of a
> before trigger.
>
> The update took 3 days, 10 hours to complete on the testing box.
That's quite a while for only 17 million rows. Are these rows
particularly wide?
Is it possible to do it by groups with a vacuum in between each group?
That would keep the bloat down.
You don't mention your vacuuming strategy. That might affect performance here.
Also, are there any FKs to / from this table?
> To minimize the impact of checkpoints. The SHARED_BUFFERS parameter has
> been bumped up to 140000 on a 20meg RAM box.
I assume you meant 20Gig box.
Under 7.4 larger shared_buffers may not be a good thing. that's a
very large shared buffer setting for 7.4 to handle.
> There are about 9 indexes on this table although none of them reference the
> date fields so since there are no inserts I don't think they would have an
> impact on the update (I've been wrong before though)
Doesn't matter. PostgreSQL's implementation of MVCC means that each
update results in a new row, and therefore each index has to be
updated for each row updated.
> Would an update statement referencing the date fields work faster than a
> trigger?
Possibly.
> Do you have any other suggestions to speed this up?
> We are at Postgres 7.4.5.
Upgrade to a modern version? 7.4 is getting old fast, and 7.4.5 has a
LOT of bugs that have been fixed in later versions. It's up to like
7.4.17 so you're missing a LOT of updates just in the branch you're
in. But upgrading to 8.2.4 would definitely be a help.
> We simply cannot afford this table to be down for 3+ days during a
> production update. The production box is a 32meg RAM box.
I would question the business process that requires an entire 17
million row table be updated.
Also, posting your schema and your triggers might help a bit as well.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: scott.marlowe@gmail.com, msteben@autorevenue.com
Subject: Re: Mass updates on a large table
In-Reply-To: <dcc563d10708101057l7dd53571w39a333988a12c84@mail.gmail.com>
References: <009601c7db75$12876c30$b501a8c0@D1RPQZB1> <dcc563d10708101057l7dd53571w39a333988a12c84@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox