Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E167AB5DC04 for ; Fri, 24 Jun 2011 10:01:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 23328-03 for ; Fri, 24 Jun 2011 13:00:54 +0000 (UTC) X-Greylist: delayed 00:08:08.186138 by SQLgrey-1.7.6 Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mail.postgresql.org (Postfix) with ESMTP id 9D060B5DC01 for ; Fri, 24 Jun 2011 10:00:54 -0300 (ADT) Received: by wwe6 with SMTP id 6so2532031wwe.19 for ; Fri, 24 Jun 2011 06:00:54 -0700 (PDT) Received: by 10.216.229.165 with SMTP id h37mr615451weq.69.1308919965659; Fri, 24 Jun 2011 05:52:45 -0700 (PDT) Received: from [192.168.41.93] (mail.optrak.co.uk [217.206.42.18]) by mx.google.com with ESMTPS id ei4sm1989781wbb.43.2011.06.24.05.52.43 (version=SSLv3 cipher=OTHER); Fri, 24 Jun 2011 05:52:44 -0700 (PDT) Message-ID: <4E04889B.2030806@optrak.com> Date: Fri, 24 Jun 2011 13:52:43 +0100 From: Mark Thornton User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 MIME-Version: 1.0 To: Harry Mantheakis CC: pgsql-performance@postgresql.org Subject: Re: Long Running Update References: <4E035649.20007@riskcontrollimited.com> In-Reply-To: <4E035649.20007@riskcontrollimited.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/227 X-Sequence-Number: 44160 On 23/06/11 16:05, Harry Mantheakis wrote: > Hello > > I am attempting to run an update statement that copies two fields from > one table to another: > > > UPDATE > table_A > SET > ( > field_1 > , field_2 > ) = ( > table_B.field_1 > , table_B.field_2 > ) > FROM > table_B > WHERE > table_B.id = table_A.id > ; > I frequently get updates involving a FROM clause wrong --- the resulting table is correct but the running time is quadratic. You might want to try a series of smaller examples to see if your query displays this behaviour. Mark Thornton