Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgK6K-000441-3A for pgsql-performance@arkaria.postgresql.org; Mon, 20 Oct 2014 21:02:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XgK6J-0006Fx-JA for pgsql-performance@arkaria.postgresql.org; Mon, 20 Oct 2014 21:02:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XgK6H-0006Fi-G9 for pgsql-performance@postgresql.org; Mon, 20 Oct 2014 21:02:45 +0000 Received: from reel.ene.cst.easter-eggs.com ([37.9.138.10]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgK67-0006u8-Sl for pgsql-performance@postgresql.org; Mon, 20 Oct 2014 21:02:42 +0000 Received: from localhost (localhost [127.0.0.1]) by reel.ene.cst.easter-eggs.com (Postfix) with ESMTP id 6C7E898F for ; Mon, 20 Oct 2014 23:02:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at reel.ene.cst.easter-eggs.com Received: from reel.ene.cst.easter-eggs.com ([127.0.0.1]) by localhost (reel.ene.cst.easter-eggs.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 35i7crWHwpmC for ; Mon, 20 Oct 2014 23:02:34 +0200 (CEST) Received: from [192.168.1.90] (mtl93-h02-176-189-198-101.dsl.sta.abo.bbox.fr [176.189.198.101]) by reel.ene.cst.easter-eggs.com (Postfix) with ESMTPSA id 392ED988 for ; Mon, 20 Oct 2014 23:02:34 +0200 (CEST) Message-ID: <54457869.3030601@enercoop.org> Date: Mon, 20 Oct 2014 23:02:33 +0200 From: Laurent Martelli User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: IS NOT NULL and LEFT JOIN References: <544339CA.5090202@enercoop.org> <5444D5FF.5070407@enercoop.org> <3181.1413813488@sss.pgh.pa.us> In-Reply-To: <3181.1413813488@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Le 20/10/2014 15:58, Tom Lane a écrit : > Laurent Martelli writes: >> Do we agree that both queries are identical ? > No, they *aren't* identical. Go consult any SQL reference. Left join > conditions don't work the way you seem to be thinking: after the join, > the RHS column might be null, rather than equal to the LHS column. Yes, I was wrong to assume that c.user_info=u.id because of the LEFT JOIN. But since I only want rows where u.id IS NOT NULL, in any case I will also have c.user_info IS NOT NULL. Also, having a foreign key, if c.user_info is not null, it will have a match in u. So in that case, either both c.user_info and c.id are null in the result rows, or they are equal. Regards, Laurent -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance