Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSRYf-00042l-Uk for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Jul 2017 17:24:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dSRYf-0002B2-HY for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Jul 2017 17:24:17 +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 1dSRYe-00029d-7n for pgsql-hackers@postgresql.org; Tue, 04 Jul 2017 17:24:16 +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 1dSRYX-00073A-J0 for pgsql-hackers@postgresql.org; Tue, 04 Jul 2017 17:24:15 +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 v64HO8Rm008089; Tue, 4 Jul 2017 13:24:08 -0400 From: Tom Lane To: Kuntal Ghosh cc: PostgreSQL-development Subject: Re: WIP patch: distinguish selectivity of < from <= and > from >= In-reply-to: <4292.1499183421@sss.pgh.pa.us> References: <12232.1499140410@sss.pgh.pa.us> <4292.1499183421@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 04 Jul 2017 11:50:21 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8087.1499189048.1@sss.pgh.pa.us> Date: Tue, 04 Jul 2017 13:24:08 -0400 Message-ID: <8088.1499189048@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org I wrote: > No, the thing that is bothering me is why it seems to be correct to > apply a positive correction for ">=", a negative correction for "<", > and no correction for "<=" or ">". That seems weird and I can't > construct a plausible explanation for it. After further thought, I can put a little more clarity to this, but it's still not really resolved. It's easily shown by experiment that the existing code correctly computes the probability that "x <= p" where p is the given probe value. It uses that value as-is for the < and <= cases, and 1 minus that value for > and >=. From this statement, it's clear why the above is the right way to correct matters. What I find remarkable is that this is what the loop computes regardless of which of the four operators is used to probe, and regardless of whether the probe value p is exactly equal to some histogram boundary value. That doesn't seem intuitive at all --- when p does match a histogram entry, you'd think it would matter which operator you probe with. (Pokes at it some more...) Oh, interesting: it behaves that way except when p is exactly the lowest histogram entry. The code is probably blowing off that edge case without enough thought. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers