Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id ED3689FB8D8 for ; Thu, 22 Feb 2007 14:25:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 35539-02 for ; Thu, 22 Feb 2007 14:25:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by postgresql.org (Postfix) with ESMTP id 18B6C9FB55B for ; Thu, 22 Feb 2007 14:25:34 -0400 (AST) Received: from trofast.ipv6.sesse.net ([2001:700:300:1803:20e:cff:fe36:a766] helo=trofast.sesse.net) by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1HKIdJ-0007t0-2K for pgsql-performance@postgresql.org; Thu, 22 Feb 2007 19:25:33 +0100 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1HKIcm-0008QQ-00 for ; Thu, 22 Feb 2007 19:25:00 +0100 Date: Thu, 22 Feb 2007 19:25:00 +0100 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: slow update on 1M rows (worse with indexes) Message-ID: <20070222182500.GA32361@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <45DDDCDE.9050806@beemotechnologie.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <45DDDCDE.9050806@beemotechnologie.com> X-Operating-System: Linux 2.6.19 on a x86_64 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.051 tagged_above=0 required=5 tests=AWL, BAYES_50 X-Spam-Level: X-Archive-Number: 200702/231 X-Sequence-Number: 23285 On Thu, Feb 22, 2007 at 07:11:42PM +0100, Gabriel Biberian wrote: > Create a new DB and load a dump of the above database with 976009 rows, > then i perform updates on the whole table. I recorded the time taken > for each full update and the amount of extra disk space used. Each > consecutive update of the table is slower than the previous > beebox@evobrik01:~$ time psql TOTO -c "UPDATE versions_9d SET flag=2" > UPDATE 976009 > real 0m41.542s You're creating a huge amount of dead rows by this kind of procedure. Try a VACUUM in-between, or enable autovacuum. (Adjusting your WAL and checkpointing settings might help too.) Apart from that, do you really have a scenario that requires updating _all_ rows in your table regularly? /* Steinar */ -- Homepage: http://www.sesse.net/