Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 8EB129FA162 for ; Wed, 13 Dec 2006 10:48:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 57668-03 for ; Wed, 13 Dec 2006 10:48:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mx3.ipf.is (man.ipf.is [85.197.192.163]) by postgresql.org (Postfix) with ESMTP id 21F939FA0EF for ; Wed, 13 Dec 2006 10:48:28 -0400 (AST) Received: (qmail 26264 invoked by uid 1010); 13 Dec 2006 14:42:01 +0000 Received: from 88.149.106.19 by man (envelope-from , uid 1008) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.4/1639. spamassassin: 3.1.4. perlscan: 1.25-st-qms. Clear:RC:1(88.149.106.19):SA:0(-2.5/4.5):. Processed in 2.567765 secs); 13 Dec 2006 14:42:01 -0000 X-Antivirus-HIVE-Mail-From: gnari@hive.is via man X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(88.149.106.19):SA:0(-2.5/4.5):. Processed in 2.567765 secs Process 26250) Received: from dsl-149-106-19.hive.is (HELO ?192.168.1.33?) (88.149.106.19) by mx3.ipf.is with SMTP; 13 Dec 2006 14:41:58 +0000 Subject: Re: Slow update with simple query From: Ragnar To: Arnaud Lesauvage Cc: Jens Schipkowski , pgsql-performance@postgresql.org In-Reply-To: <4580025D.2040903@freesurf.fr> References: <457FDB1E.6040801@freesurf.fr> <457FF0CD.4050606@freesurf.fr> <4580025D.2040903@freesurf.fr> Content-Type: text/plain; charset=ISO-8859-1 Date: Wed, 13 Dec 2006 14:49:00 +0000 Message-Id: <1166021340.6369.103.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/320 X-Sequence-Number: 22376 On miğ, 2006-12-13 at 14:38 +0100, Arnaud Lesauvage wrote: > Jens Schipkowski a écrit : > > On Wed, 13 Dec 2006 13:23:41 +0100, Arnaud Lesauvage > >> Why is this query better than the other one ? Because it runs the > >> "(field IN ('some','other') AND field2 = 'Y')" once and then executes > >> the join with the resulting set ? > > True. The Subselect in FROM clause will be executed once and will be > > joined using the condition at where clause. So your condition at t2 is not > > executed for each row in t1(2mio records) but for each row in t2(1k > > records). And the boolean value is already set during update. > > OK Jens, thanks for clarifying this. > I thought the planner could guess what to do in such cases. don't worry, it will. this is not your problem gnari