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 E14CE5E4714 for ; Wed, 1 Sep 2004 02:32:15 -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 02919-10 for ; Wed, 1 Sep 2004 05:32:09 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 37AFC5E46F8 for ; Wed, 1 Sep 2004 02:32:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i815W9n7001615; Wed, 1 Sep 2004 01:32:09 -0400 (EDT) To: Ron St-Pierre Cc: pgsql-performance@postgresql.org Subject: Re: Table UPDATE is too slow In-reply-to: <4134BF36.3000504@syscor.com> References: <4134BF36.3000504@syscor.com> Comments: In-reply-to Ron St-Pierre message dated "Tue, 31 Aug 2004 11:11:02 -0700" Date: Wed, 01 Sep 2004 01:32:08 -0400 Message-ID: <1613.1094016728@sss.pgh.pa.us> From: Tom Lane 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: 200409/1 X-Sequence-Number: 8129 Ron St-Pierre writes: > Does anyone have some idea on how we can increase speed, either by > changing the updates, designing the database > differently, etc, etc? This is currently a big problem for us. > Other notables: > The UPDATE is run from a within a function: FOR rec IN SELECT ...LOOP > RETURN NEXT rec; UPDATE dataTable..... One point that I don't think was made before: by doing a collection of updates in this serial one-at-a-time fashion, you are precluding any possibility of query optimization over the collection of updates. It might win to dump the update data into a temp table and do a single UPDATE command joining to the temp table. Or not --- quite possibly not --- but I think it's something to think about. regards, tom lane