Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgpQD-0005ui-Ex for pgsql-performance@arkaria.postgresql.org; Wed, 22 Oct 2014 06:29:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XgpQC-0007pH-Tc for pgsql-performance@arkaria.postgresql.org; Wed, 22 Oct 2014 06:29:24 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XgpQC-0007pB-17 for pgsql-performance@postgresql.org; Wed, 22 Oct 2014 06:29:24 +0000 Received: from reel.ene.cst.easter-eggs.com ([37.9.138.10]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XgpQ8-0002Ru-Nr for pgsql-performance@postgresql.org; Wed, 22 Oct 2014 06:29:22 +0000 Received: from localhost (localhost [127.0.0.1]) by reel.ene.cst.easter-eggs.com (Postfix) with ESMTP id ADBFF4B5; Wed, 22 Oct 2014 08:29:18 +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 lQTRD3led5XU; Wed, 22 Oct 2014 08:29:18 +0200 (CEST) Received: by reel.ene.cst.easter-eggs.com (Postfix, from userid 999) id 8A2A050D; Wed, 22 Oct 2014 08:29:18 +0200 (CEST) User-Agent: SOGoMail 2.2.3 cc: "Tom Lane" , "pgsql-performance" X-Forward: 82.127.127.10 MIME-Version: 1.0 from: "Laurent Martelli" Subject: Re: IS NOT NULL and LEFT JOIN message-id: <7fe0-54474e80-27-1379daa0@249371065> to: "David Rowley" content-type: text/plain; charset="utf-8" date: Wed, 22 Oct 2014 08:29:18 +0200 in-reply-to: content-transfer-encoding: quoted-printable 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 Mardi 21 Octobre 2014 10:44 CEST, David Rowley a = =C3=A9crit: > For what it's worth I'd say they are identical, at least, if you discount > deferring foreign key constraints or also executing the query from within > a volatile function which was called by a query which just updated the > user_info table to break referential integrity. I must say I had not thought of that. > The presence of the foreign key on contract_contract.user_info which > references user_user_info.id means that any non-null > contract_contract.user_info record must reference a valid user_user_info > record, therefore the join is not required to prove that a non nulled > user_info contract records match a user info record, therefore the join to > check it exists is pretty much pointless in just about all cases that > you're likely to care about. > > Although, saying that I'm still a bit confused about the question. Are you > asking if there's some way to get PostgreSQL to run the 1st query faster? > Or are you asking if both queries are equivalent? I was asking for a way to make it run faster. Given that it returns at most= a few rows found by an index, I was thinking it could be made to run faste= r. But I agree that the query is not well written (well generated by hibernate= ) considering the result I want. Regards, Laurent --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance