Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 977379FA02C for ; Wed, 13 Dec 2006 09:38:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 71174-08 for ; Wed, 13 Dec 2006 09:38:39 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from serveurmail01.codata.be (125.123.146.82.ipv4.evonet.be [82.146.123.125]) by postgresql.org (Postfix) with ESMTP id A3A909F9F49 for ; Wed, 13 Dec 2006 09:38:44 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by serveurmail01.codata.be (Postfix) with ESMTP id 33EEF183877C; Wed, 13 Dec 2006 14:38:43 +0100 (CET) X-DSPAM-Result: Innocent X-DSPAM-Processed: Wed Dec 13 14:38:38 2006 X-DSPAM-Confidence: 0.7829 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 4580025e277021293013182 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at Received: from serveurmail01.codata.be ([127.0.0.1]) by localhost (serveurmail01.codata.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vOhRPCcziXYO; Wed, 13 Dec 2006 14:38:38 +0100 (CET) Received: from [127.0.0.1] (38-179-112-217.fix.adsl.belcenter.be [217.112.179.38]) by serveurmail01.codata.be (Postfix) with ESMTP id 15BD41838778; Wed, 13 Dec 2006 14:38:38 +0100 (CET) Message-ID: <4580025D.2040903@freesurf.fr> Date: Wed, 13 Dec 2006 14:38:37 +0100 From: Arnaud Lesauvage User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Jens Schipkowski CC: pgsql-performance@postgresql.org Subject: Re: Slow update with simple query References: <457FDB1E.6040801@freesurf.fr> <457FF0CD.4050606@freesurf.fr> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 0657-2, 12/12/2006), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/319 X-Sequence-Number: 22375 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. Regards -- Arnaud