X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CC9B6D8A7E for ; Mon, 12 Sep 2005 11:07:25 -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 39538-02 for ; Mon, 12 Sep 2005 14:07:21 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A207ED86E1 for ; Mon, 12 Sep 2005 11:07:23 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j8CE7QVG021153; Mon, 12 Sep 2005 10:07:26 -0400 (EDT) To: Hilary Forbes Cc: pgsql-performance@postgresql.org Subject: Re: Slow update In-reply-to: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> References: <5.1.0.14.0.20050912100150.01f47f18@mailserver.dmr.co.uk> Comments: In-reply-to Hilary Forbes message dated "Mon, 12 Sep 2005 10:14:25 +0100" Date: Mon, 12 Sep 2005 10:07:26 -0400 Message-ID: <21152.1126534046@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/143 X-Sequence-Number: 14451 Hilary Forbes writes: > I need to set the value of a field in table A to a value in table B depending on the existence of the record in table B. So what I have done is > UPDATE tableA set a.val1=b.somefield FROM tableA a, tableB b WHERE a.key1=b.key1; You've written an unconstrained join to a second copy of tableA. regards, tom lane