Re: Updates on large tables are extremely slow - Mailing list pgsql-performance

From Jacques Caron
Subject Re: Updates on large tables are extremely slow
Date
Msg-id 6.2.0.14.0.20050612195157.039cd170@pop.interactivemediafactory.net
Whole thread Raw
In response to Updates on large tables are extremely slow  (Yves Vindevogel <yves.vindevogel@implements.be>)
List pgsql-performance
Hi,

At 19:40 12/06/2005, Yves Vindevogel wrote:
>Hi,
>
>I'm trying to update a table that has about 600.000 records.
>The update query is very simple  :    update mytable set pagesdesc = -
>pages ;
>
>(I use pagesdesc to avoid problems with sort that have one field in
>ascending order and one in descending order.  That was a problem I had a
>week ago)

An index on (-pages) would probably do exactly what you want without having
to add another column.

>The query takes about half an hour to an hour to execute.

Depending on the total size of the table and associated indexes and on your
exact setup (especially your hardare), this could be quite normal: the
exuctor goes through all rows in the table, and for each, creates a copy
with the additional column, updates indexes, and logs to WAL. You might
want to look into moving your WAL files (pg_xlog) to a separate disk,
increase WAL and checkpoint buffers, add more RAM, add more disks...

But as I said, you might not even need to do that, just use an index on an
expression...

Jacques.



pgsql-performance by date:

Previous
From: Yves Vindevogel
Date:
Subject: Updates on large tables are extremely slow
Next
From: Madison Kelly
Date:
Subject: Re: Index ot being used