X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B430D5E46C3 for ; Tue, 31 Aug 2004 15:18:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06934-04 for ; Tue, 31 Aug 2004 18:18:17 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id ADF9C5E46F8 for ; Tue, 31 Aug 2004 15:18:16 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1C2DCx-0006M2-00 for ; Tue, 31 Aug 2004 20:18:15 +0200 Date: Tue, 31 Aug 2004 20:18:15 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Table UPDATE is too slow Message-ID: <20040831181815.GB24253@uio.no> References: <4134BF36.3000504@syscor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4134BF36.3000504@syscor.com> X-Operating-System: Linux 2.6.6 on a i686 User-Agent: Mutt/1.5.6+20040818i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/469 X-Sequence-Number: 8105 On Tue, Aug 31, 2004 at 11:11:02AM -0700, Ron St-Pierre wrote: > We have a web based application with data that is updated daily. The > biggest bottleneck occurs when we try to update > one of the tables. This table contains 58,000 rows and 62 columns, and > EVERY column is indexed. That is usually a very bad idea; for every update, PostgreSQL has to update 62 indexes. Do you really do queries on all those 62 columns? > A typical update is: > UPDATE dataTable SET field01=44.5, field02=44.5, field03='Bob', > field04='foo', ... , field60='2004-08-30', field61='2004-08-29' > WHERE id = 1234; That looks like poor database normalization, really. Are you sure you don't want to split this into multiple tables instead of having 62 columns? > Other notables: > The UPDATE is run from a within a function: FOR rec IN SELECT ...LOOP > RETURN NEXT rec; UPDATE dataTable..... > Postgres 7.4.3 > debian stable > 2 GB RAM > 80 DB IDE drive (we can't change it) Are you doing all this in multiple transactions, or in a sngle one? Wrapping the FOR loop in a transaction might help speed. /* Steinar */ -- Homepage: http://www.sesse.net/