Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8zf4-0006sG-7x for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Apr 2018 02:51:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f8zf3-000507-7I for pgsql-bugs@arkaria.postgresql.org; Thu, 19 Apr 2018 02:51:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8zf3-0004zy-15 for pgsql-bugs@lists.postgresql.org; Thu, 19 Apr 2018 02:51:01 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f8zez-0001tB-JJ for pgsql-bugs@lists.postgresql.org; Thu, 19 Apr 2018 02:51:00 +0000 Received: from [192.168.127.1] (port=14694 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1f8zew-000PpD-KC; Thu, 19 Apr 2018 02:50:54 +0000 Received: from [127.0.0.1] (port=52467 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1f8zev-000LqG-Nb; Thu, 19 Apr 2018 02:50:53 +0000 From: Andrew Gierth To: Andreas Karlsson Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Ignored join clause In-Reply-To: (Andreas Karlsson's message of "Thu, 19 Apr 2018 01:34:47 +0200") Message-ID: <87muy0dk4a.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 19 Apr 2018 03:50:52 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Andreas" == Andreas Karlsson writes: Andreas> Hi, Andreas> It seems to me like PostgreSQL incorrectly removes a join Andreas> clause when planning some queries. I discovered this while Andreas> debugging a large query, which I below have simplified as much Andreas> as I could. I suspect the bug may be related to the lateral Andreas> join but I am not sure. Fascinating. What's happening here is not that the condition is being ignored, but rather that what should be a simple filter condition (or a join filter at the upper level) is being placed in the "Join Filter" slot of an outer join at the inner level - where the condition's falsity doesn't remove the whole row but causes it to be treated as unmatched. My suspicion is that this is an interaction between lateral and join reordering. Looking into it further. -- Andrew (irc:RhodiumToad)