Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2D18E6501B3 for ; Mon, 22 Dec 2008 08:54:37 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 07771-01 for ; Mon, 22 Dec 2008 08:54:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from viefep18-int.chello.at (viefep13-int.chello.at [62.179.121.33]) by mail.postgresql.org (Postfix) with ESMTP id 2E28065034B for ; Mon, 22 Dec 2008 08:54:24 -0400 (AST) Received: from edge05.upc.biz ([192.168.13.212]) by viefep13-int.chello.at (InterMail vM.7.09.01.00 201-2219-108-20080618) with ESMTP id <20081222125422.MBAZ17187.viefep13-int.chello.at@edge05.upc.biz>; Mon, 22 Dec 2008 13:54:22 +0100 Received: from [192.168.1.104] ([89.134.230.11]) by edge05.upc.biz with edge id uCuL1a01l0FQLHV05CuMeS; Mon, 22 Dec 2008 13:54:22 +0100 X-SourceIP: 89.134.230.11 Message-ID: <494F8DFC.1000001@shopzeus.com> Date: Mon, 22 Dec 2008 13:54:20 +0100 From: Laszlo Nagy User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: Gregory Williamson , "pgsql-performance@postgresql.org" CC: Daniel Fekete Subject: Re: Slow table update References: <494F749A.5090603@shopzeus.com> <494F7B48.6070204@shopzeus.com> <8B319E5A30FF4A48BE7EEAAF609DB233021F389A@COMAIL01.digitalglobe.com> In-Reply-To: <8B319E5A30FF4A48BE7EEAAF609DB233021F389A@COMAIL01.digitalglobe.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.125 tagged_above=0 required=5 tests=DNS_FROM_RFC_BOGUSMX=2.125 X-Spam-Level: ** X-Archive-Number: 200812/188 X-Sequence-Number: 32224 > > If the table has some sort of FK relations it might be being slowed by > the need to check a row meant to be deleted has any children. > If you look at my SQL, there is only one column to be updated. That column has no foreign key constraint. (It should have, but we did not want to add that constraint in order to speed up updates.) > > > Perhaps triggers ? > Table "product" has no triggers. > > > If the table is very bloated with lots of dead rows (but you did say > you vacuum frequently and check the results to make sure they are > effective?) that would slow it down. > I'm not sure how to check if the vacuum was effective. But we have max_fsm_pages=1000000 in postgresql.conf, and I do not get any errors from the daily vacuum script, so I presume that the table hasn't got too many dead rows. Anyway, the table size is only 4GB. Even if half of the rows are dead, the update should run quite quickly. Another argument is that when I "select count(*)" instead of "UPDATE", then I get the result in 10 seconds. I don't think that dead rows can make such a big difference between reading and writing. My other idea was that there are so many indexes on this table, maybe the update is slow because of the indexes? The column being updated has only one index on it, and that is 200MB. But I have heard somewhere that because of PostgreSQL's multi version system, sometimes the system needs to update indexes with columns that are not being updated. I'm not sure. Might this be the problem? > > > A long running transaction elsewhere that is blocking the delete ? Did > you check the locks ? > Sorry, this was an update. A blocking transaction would never explain why the disk I/O went up to 100% for 2600 seconds. L