pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kuntal Ghosh <kuntalghosh.2007@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: WIP patch: distinguish selectivity of < from <= and > from >=
Date: Tue, 04 Jul 2017 13:24:08 -0400
Message-ID: <8088.1499189048@sss.pgh.pa.us> (raw)
In-Reply-To: <4292.1499183421@sss.pgh.pa.us>
References: <12232.1499140410@sss.pgh.pa.us>
	<CAGz5QCKTW6YQNe6Ttqj-Zx_W34vmwz5jP_Cs1KC7j7yHriLVxw@mail.gmail.com>
	<4292.1499183421@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

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



view thread (19+ messages)  latest in thread

Message-ID: <8088.1499189048@sss.pgh.pa.us>
Permalink:  ../8088.1499189048@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8088.1499189048@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kuntalghosh.2007@gmail.com
  Subject: Re: WIP patch: distinguish selectivity of < from <= and > from >=
  In-Reply-To: <8088.1499189048@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox