Re: Statistics and selectivity estimation for ranges

Alexander Korotkov <aekorotkov@gmail.com>

From: Alexander Korotkov <aekorotkov@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2012-12-13T20:40:33Z
Lists: pgsql-hackers

Attachments

Hi, Jeff!

Thanks a lot for review!

On Mon, Dec 10, 2012 at 11:21 PM, Jeff Davis <pgsql@j-davis.com> wrote:

> It looks like there are still some problems with this patch.
>
>   CREATE TABLE foo(ir int4range);
>   insert into foo select 'empty' from generate_series(1,10000);
>   insert into foo select int4range(NULL, g, '(]')
>     from generate_series(1,1000000) g;
>   insert into foo select int4range(g, NULL, '[)')
>     from generate_series(1,1000000) g;
>   insert into foo select int4range(g, ((g*1.01)+10)::int4, '[]')
>     from generate_series(1,1000000) g;
>   CREATE TABLE bar(ir) AS select * from foo order by random();
>   ANALYZE bar;
>
> Now:
>   EXPLAIN ANALYZE SELECT * FROM bar
>     WHERE ir @> int4range(10000,20000);
>
> The estimates are "-nan". Similar for many other queries.
>

Oh, yeah! It appears that infinities require much more cautious work with
them than I supposed. That should be fixes in the attached version of
patch. However, it require significant rethinking of comments. Will update
comments and address your questions in a couple of days. Could you recheck
if attached patch really fixes problem you reported?

------
With best regards,
Alexander Korotkov.