Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2025-04-17 Thread Andrei Lepikhov
On 6/24/23 13:23, Tomas Vondra wrote: I really hope what I just wrote makes at least a little bit of sense. Here is a continuation of your work: 1. non-matched estimation sophisticated to provide meaningful numbers. 2. unmatched_frac is stored in sjinfo that let us to summarise these generated

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-07-16 Thread Alena Rybakina
Hi, I'm still working on it, but, unfortunately, I didn't have much time to work with it well enough that there would be something that could be shown. Now I am trying to sort out the problems that I drew attention to in the previous letter. -- Regards, Alena Rybakina Postgres Professional

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-07-10 Thread Alena Rybakina
Well, I don't have a detailed plan either. In principle it shouldn't be that hard, I think - examine_variable is loading the statistics, so it could apply the same null_frac correction, just like nulltestsel would do a bit later. The main question is how to pass the information to examine_variabl

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-07-08 Thread Tomas Vondra
On 7/8/23 10:29, Alena Rybakina wrote: > >> Well, one option would be to modify all selectivity functions to do >> something like the patch does for nulltestsel(). That seems a bit >> cumbersome because why should those places care about maybe running on >> the outer side of a join, or what? Fo

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-07-08 Thread Alena Rybakina
Well, one option would be to modify all selectivity functions to do something like the patch does for nulltestsel(). That seems a bit cumbersome because why should those places care about maybe running on the outer side of a join, or what? For code in extensions this would be particularly probl

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-07-06 Thread Tomas Vondra
On 7/6/23 15:51, Alena Rybakina wrote: > Hi, all! > > On 26.06.2023 12:22, Andrey Lepikhov wrote: >> On 24/6/2023 17:23, Tomas Vondra wrote: >>> I really hope what I just wrote makes at least a little bit of sense. >> Throw in one more example: >> >> SELECT i AS id INTO l FROM generate_series(1

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-07-06 Thread Alena Rybakina
Hi, all! On 26.06.2023 12:22, Andrey Lepikhov wrote: On 24/6/2023 17:23, Tomas Vondra wrote: I really hope what I just wrote makes at least a little bit of sense. Throw in one more example: SELECT i AS id INTO l FROM generate_series(1,10) i; CREATE TABLE r (id int8, v text); INSERT INTO r

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-06-28 Thread Tomas Vondra
On 6/26/23 20:15, Alena Rybakina wrote: > Hi, all! > > On 24.06.2023 14:23, Tomas Vondra wrote: >> On 6/24/23 02:08, Tom Lane wrote: >>> Tomas Vondra writes: The problem is that the selectivity for "IS NULL" is estimated using the table-level statistics. But the LEFT JOIN entirely br

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-06-26 Thread Alena Rybakina
Hi, all! On 24.06.2023 14:23, Tomas Vondra wrote: On 6/24/23 02:08, Tom Lane wrote: Tomas Vondra writes: The problem is that the selectivity for "IS NULL" is estimated using the table-level statistics. But the LEFT JOIN entirely breaks the idea that the null_frac has anything to do with NULLs

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-06-26 Thread Andrey Lepikhov
On 24/6/2023 17:23, Tomas Vondra wrote: I really hope what I just wrote makes at least a little bit of sense. Throw in one more example: SELECT i AS id INTO l FROM generate_series(1,10) i; CREATE TABLE r (id int8, v text); INSERT INTO r (id, v) VALUES (1, 't'), (-1, 'f'); ANALYZE l,r; EXPLA

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-06-24 Thread Tomas Vondra
On 6/24/23 02:08, Tom Lane wrote: > Tomas Vondra writes: >> The problem is that the selectivity for "IS NULL" is estimated using the >> table-level statistics. But the LEFT JOIN entirely breaks the idea that >> the null_frac has anything to do with NULLs in the join result. > > Right. > >> I won

Re: Problems with estimating OR conditions, IS NULL on LEFT JOINs

2023-06-23 Thread Tom Lane
Tomas Vondra writes: > The problem is that the selectivity for "IS NULL" is estimated using the > table-level statistics. But the LEFT JOIN entirely breaks the idea that > the null_frac has anything to do with NULLs in the join result. Right. > I wonder how to improve this, say by adjusting the