Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-09-13 Thread Tom Lane
Kuntal Ghosh writes: > On Tue, Sep 12, 2017 at 9:47 PM, Tom Lane wrote: >> Aleksander Alekseev writes: >>> The following review has been posted through the commitfest application: >>> make installcheck-world: tested,

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-09-13 Thread Kuntal Ghosh
On Tue, Sep 12, 2017 at 9:47 PM, Tom Lane wrote: > Aleksander Alekseev writes: >> The following review has been posted through the commitfest application: >> make installcheck-world: tested, passed >> Implements feature: tested, passed >>

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-09-13 Thread Aleksander Alekseev
Hi Tom, > Thanks for reviewing! I assume this is against the prior version of the > patch, though, not the one I just posted with updates for contrib. > Do you want to look at those? > > regards, tom lane No, I reviewed the latest v4 patch right after you submitted it.

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-09-12 Thread Tom Lane
Aleksander Alekseev writes: > The following review has been posted through the commitfest application: > make installcheck-world: tested, passed > Implements feature: tested, passed > Spec compliant: tested, passed > Documentation:tested,

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-09-12 Thread Aleksander Alekseev
The following review has been posted through the commitfest application: make installcheck-world: tested, passed Implements feature: tested, passed Spec compliant: tested, passed Documentation:tested, passed Also I didn't manage to find any typos or obvious mistakes

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-09-12 Thread Tom Lane
Here's an updated version of this patch that is rebased against HEAD (no changes there except line numbers) and adds the necessary updates for contrib. I'd like to get this committed fairly soon before it bit-rots. Anyone want to review it? regards, tom lane diff --git

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-09 Thread Kuntal Ghosh
On Fri, Jul 7, 2017 at 2:53 AM, Tom Lane wrote: > Kuntal Ghosh writes: Wow. Thank you for the wonderful explanation. >> On Thu, Jul 6, 2017 at 3:45 AM, Tom Lane wrote: > >> if histogram_bounds are assigned as, >>

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-07 Thread Tom Lane
I wrote: > I looked at that again and realized that one of the answers I was missing > lies in the behavior of analyze.c's compute_scalar_stats(). I updated the patch's comments based on this. I'll just attach the selfuncs.c part of the patch, since nothing else changed.

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-06 Thread Tom Lane
Kuntal Ghosh writes: > On Thu, Jul 6, 2017 at 3:45 AM, Tom Lane wrote: > + * In the first bin (i==1), add a fudge factor that ensures > + * that histfrac is at least eq_selec. We do this because we > + * know that the first histogram entry does

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-06 Thread Kuntal Ghosh
On Thu, Jul 6, 2017 at 3:45 AM, Tom Lane wrote: > I wrote: >> (Pokes at it some more...) Oh, interesting: it behaves that way except >> when p is exactly the lowest histogram entry. > + /* + * In the first bin (i==1), add a fudge factor that ensures + * that histfrac is at

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-05 Thread Tom Lane
I wrote: > (Pokes at it some more...) Oh, interesting: it behaves that way except > when p is exactly the lowest histogram entry. Here's a revised version that addresses that point and cleans up some other minor details about treatment of cases near the histogram endpoints. I'm still pretty

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Kuntal Ghosh
On Tue, Jul 4, 2017 at 10:56 PM, Kuntal Ghosh wrote: > On Tue, Jul 4, 2017 at 9:20 PM, Tom Lane wrote: >> Kuntal Ghosh writes: >>> On Tue, Jul 4, 2017 at 9:23 AM, Tom Lane wrote: ... I have to

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Kuntal Ghosh
On Tue, Jul 4, 2017 at 9:20 PM, Tom Lane wrote: > Kuntal Ghosh writes: >> On Tue, Jul 4, 2017 at 9:23 AM, Tom Lane wrote: >>> ... I have to admit that I've failed to wrap my brain around exactly >>> why it's correct. The

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Tom Lane
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

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Tom Lane
Kuntal Ghosh writes: > On Tue, Jul 4, 2017 at 9:23 AM, Tom Lane wrote: >> ... I have to admit that I've failed to wrap my brain around exactly >> why it's correct. The arguments that I've constructed so far seem to >> point in the direction of

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Kuntal Ghosh
On Tue, Jul 4, 2017 at 9:23 AM, Tom Lane wrote: > Aside from the mind-bendingly-tedious changes in pg_operator.h, the meat > of the patch is in selfuncs.c's ineq_histogram_selectivity(), which now > applies a correction for equal values in the cases where we were getting > it

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Tom Lane
Ashutosh Bapat writes: > On Tue, Jul 4, 2017 at 9:23 AM, Tom Lane wrote: >> regression=# explain analyze select * from tenk1 where thousand < 10; >> before: >> Bitmap Heap Scan on tenk1 (cost=5.14..241.38 rows=110 width=244) (actual >>

Re: [HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-04 Thread Ashutosh Bapat
On Tue, Jul 4, 2017 at 9:23 AM, Tom Lane wrote: > > regression=# explain analyze select * from tenk1 where thousand < 10; > before: > Bitmap Heap Scan on tenk1 (cost=5.14..241.38 rows=110 width=244) (actual > time=0.121..0.623 rows=100 loops=1) > with patch: > Bitmap Heap

[HACKERS] WIP patch: distinguish selectivity of < from <= and > from >=

2017-07-03 Thread Tom Lane
I was reminded by bug #14729 that we are not very good on corner cases involving inequality operators, ie < <= > >=. Historically, the selectivity functions have simply not distinguished < from <= or > from >=, arguing that the fraction of the population that satisfies the "=" aspect can be