Re: [SQL] Bad update performance? - Mailing list pgsql-general

From Tom Lane
Subject Re: [SQL] Bad update performance?
Date
Msg-id 1666.932564293@sss.pgh.pa.us
Whole thread Raw
In response to Bad update performance?  ("Gunnar Ingvi Thorisson" <gunni@if.is>)
List pgsql-general
"Gunnar Ingvi Thorisson" <gunni@if.is> writes:
> I�ve a table with about 142000 rows like shown below and I want to
> set field "divis" to "unknown" by executing following update command:
> update ipacct set divis = 'unknown';
> However this seems to take hours,

Well, updating 142000 rows is going to take a little while...

Are you starting the postmaster with -o -F ?  That makes for a pretty
considerable speedup in most cases (at the cost of trouble if you
have a system crash during an update).

> Does indexing the field "divis" speed up the update performance?

No, it would not help a query like that --- though if you added a clause
like "where divis = 'oldvalue'" then an index would help to find the
rows that need updated.  Actually, every index you add *slows down*
updates, since all the indexes must be updated along with the table.

            regards, tom lane

pgsql-general by date:

Previous
From: Chris Bitmead
Date:
Subject: inheritance
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] inheritance