X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 85B6614B287A for ; Wed, 11 Aug 2004 23:19:10 -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 10622-08 for ; Thu, 12 Aug 2004 02:19:04 +0000 (GMT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 4D27214B2878 for ; Wed, 11 Aug 2004 23:19:02 -0300 (ADT) Received: (qmail 23739 invoked by uid 500); 12 Aug 2004 02:27:15 -0000 Date: Wed, 11 Aug 2004 21:27:15 -0500 From: Bruno Wolff III To: David Stanaway Cc: pgsql-sql Subject: Re: UPDATE FROM problem, multiple updates of same row don't seem to work Message-ID: <20040812022715.GB22747@wolff.to> Mail-Followup-To: David Stanaway , pgsql-sql References: <1092082589.7197.3.camel@dmxnocws13.dialmex.net> <20040811235241.GB19680@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i 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/104 X-Sequence-Number: 18601 On Wed, Aug 11, 2004 at 20:50:28 -0500, David Stanaway wrote: > > I had thought about that, but this is a simpler case of what I need to > do. The operations for each column in the update are dependent on the > current and new values of each row being merged. > > Currently I am doing this with a cursor which is very slow! How about a > trigger on update? Or would this suffer the same behavior that I am > seeing with UPDATE FROM with a 1-many join? There is a good chance that triggers would be faster since tablea seems to reallly be a materialized view of an aggregate over tableb and doing a delta calculation when a row changes is going to be faster than recalculating the aggregate from scratch. You won't have the same problem if you use a trigger as when you were trying to calculate an aggregate using UPDATE.