Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 44FEADE314E for ; Tue, 3 Apr 2012 14:50:17 -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 1SF7rz-0002FR-Ci for pgsql-performance@postgresql.org; Tue, 03 Apr 2012 17:50:16 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Tue, 03 Apr 2012 12:50:02 -0500 Message-Id: <4F7AF1F20200002500046B3F@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.2 Date: Tue, 03 Apr 2012 12:49:54 -0500 From: "Kevin Grittner" To: "Kevin Kempter" , "Andrew Dunstan" Cc: "pgsql-performance@postgresql.org" Subject: Re: Update join performance issues References: <4F7B3394.3030703@consistentstate.com> <4F7B35B9.50108@dunslane.net> In-Reply-To: <4F7B35B9.50108@dunslane.net> 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/31 X-Sequence-Number: 46677 Andrew Dunstan wrote: > Why is test_one in the from clause? update joins whatever is in > the from clause to the table being updated. You almost never need > it repeated in the from clause. This is actually one of the nastier "gotchas" in converting from Sybase ASE or MS SQL Server to PostgreSQL -- there are syntactically identical UPDATE statements with very different semantics when a FROM clause is used in an UPDATE statement. You need to do what the OP was showing to use an alias with the target table under those other products. I suppose it might be possible to generate a warning when it appears that someone is making this mistake, but it wouldn't be easy and would probably not be worth the carrying cost. The test would need to be something like: (1) The relation which is the target of the UPDATE has no alias. (2) There is a FROM clause which included the target relation (with an alias). (3) There aren't any joining references between the UPDATE target and the relation(s) in the FROM clause. -Kevin