Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 96BA9DE314D for ; Tue, 3 Apr 2012 14:38:09 -0300 (ADT) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SF7gG-000244-Ih for pgsql-performance@postgresql.org; Tue, 03 Apr 2012 17:38:09 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Tue, 03 Apr 2012 12:37:55 -0500 Message-Id: <4F7AEF1E0200002500046B35@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.2 Date: Tue, 03 Apr 2012 12:37:50 -0500 From: "Kevin Grittner" To: "Kevin Kempter" , "pgsql-performance@postgresql.org" Subject: Re: Update join performance issues References: <4F7B3394.3030703@consistentstate.com> In-Reply-To: <4F7B3394.3030703@consistentstate.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201204/29 X-Sequence-Number: 46675 Kevin Kempter wrote: > update test_one > set f_key = t.f_key > from > upd_temp1 t, > test_one t2 > where > t.id_number = t2.id_number As written above, it is joining the two table references in the FROM clause and updating every row in test_one with every row in the JOIN -- which is probably not what you want. Having a FROM clause on an UPDATE statement is not something which is covered by the standard, and different products have implemented different semantics for that. For example, under MS SQL Server, the first reference in the FROM clause to the target of the UPDATE is considered to be the same reference; so the above statement would be accepted, but do something very different. You probably want this: update test_one t2 set f_key = t.f_key from upd_temp1 t where t.id_number = t2.id_number -Kevin