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 93E395E470C for ; Tue, 31 Aug 2004 15:48:52 -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 18018-02 for ; Tue, 31 Aug 2004 18:48:46 +0000 (GMT) Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) by svr1.postgresql.org (Postfix) with ESMTP id F27885E470A for ; Tue, 31 Aug 2004 15:48:45 -0300 (ADT) Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1C2DgT-0006VF-00 for ; Tue, 31 Aug 2004 20:48:45 +0200 Date: Tue, 31 Aug 2004 20:48:45 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Table UPDATE is too slow Message-ID: <20040831184845.GA24976@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <4134BF36.3000504@syscor.com> <20040831181815.GB24253@uio.no> <4134C4FA.20404@syscor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4134C4FA.20404@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=1.2 tagged_above=0.0 required=5.0 tests=NO_EXPERIENCE X-Spam-Level: * X-Archive-Number: 200408/473 X-Sequence-Number: 8109 On Tue, Aug 31, 2004 at 11:35:38AM -0700, Ron St-Pierre wrote: > We're doing it in multiple transactions within the function. Could we do > something like this?: > > .... > BEGIN > FOR rec IN SELECT field01, field02, ... FROM otherTable LOOP > RETURN NEXT rec; > UPDATE dataTable SET field01=rec.field01, field02=rec.field02, > rec.field03=field03, ... > WHERE id = rec.id; > COMMIT; > .... > > > If we can do it this way, are there any other gotcha's we should be > aware of? AFAIK you should be able to do this, yes (although I have no experience with PL/SQL); I'm not sure how much it buys you, but you might want to test it, at least. /* Steinar */ -- Homepage: http://www.sesse.net/