Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGSsG-0003dT-O3 for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Jun 2017 16:23:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dGSsE-0001oy-Jk for pgsql-bugs@arkaria.postgresql.org; Thu, 01 Jun 2017 16:22:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dGSsD-0001o9-KT for pgsql-bugs@postgresql.org; Thu, 01 Jun 2017 16:22:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dGSsB-0004SH-4c for pgsql-bugs@postgresql.org; Thu, 01 Jun 2017 16:22:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v51GMr7Z004699; Thu, 1 Jun 2017 12:22:53 -0400 From: Tom Lane To: marko@joh.to cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14676: neqsel is NULL dumb In-reply-to: <20170529153847.4275.95416@wrigleys.postgresql.org> References: <20170529153847.4275.95416@wrigleys.postgresql.org> Comments: In-reply-to marko@joh.to message dated "Mon, 29 May 2017 15:38:47 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4697.1496334173.1@sss.pgh.pa.us> Date: Thu, 01 Jun 2017 12:22:53 -0400 Message-ID: <4698.1496334173@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org marko@joh.to writes: > This seems to be because neqsel() doesn't take at all into account that both > operators will exclude NULL rows, and does a simple 1.0 - eqsel(). Yeah, that's clearly broken. A localized fix would be to re-fetch the nullfrac statistic and subtract it off, but that seems pretty inefficient. I'd be inclined to refactor things so that eqsel() and neqsel() call a common routine that takes a "bool negate" argument, about like the way the patternsel() functions work, and then the common routine could handle the nullfrac correctly for both cases. Hmm ... actually, I think patternsel() is broken for this case too --- it has the information to do the right thing, but it doesn't look like it actually is doing it: return negate ? (1.0 - result) : result; should be more like return negate ? (1.0 - result - nullfrac) : result; neqjoinsel has a similar issue, and I'm not sure what else. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs