Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 1949F476538 for ; Wed, 8 May 2002 13:35:39 -0400 (EDT) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id A4B3947632F for ; Wed, 8 May 2002 12:10:42 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id MAA02761 for ; Wed, 8 May 2002 12:10:44 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma002759; Wed, 8 May 02 12:10:23 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id MAA24151 for ; Wed, 8 May 2002 12:10:23 -0400 Message-ID: <3CD94F3C.4B116582@nsd.ca> Date: Wed, 08 May 2002 12:15:56 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Performance on update from join References: <20020507142203.4114.qmail@uwdvg001.cms.usa.net> <200205081145.37254.mallah@trade-india.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200205/52 X-Sequence-Number: 7688 Hi all, Hi Tom, I was exploring ways to improve the time required to update a large table from the join of two others as in: UPDATE a FROM b, c; I found that whatever index I create, compound or not, PG insist on performing the cartesian product first. Now, if "b" and "c" are relatively small, that make sense, but when the cartesian product of "b" and "c" is and order of magnitude larger than "a" it makes no sense at all. Shouldn't the number of rows in "b" and "c" be reduced to the matching the criterias on "a" first? If "b" is meant to be a many to one relation to "c", shouldn't "a" be joined to "b" first? Is there a way I can force the "a" join "b" first? I also tried to do it in a PLPGSQL FOR LOOP, but because the script is processed as a transaction, I do not get much better performance. It would sure be nice to be able to commit the change on a row per row basis. THX jll