EITS: bad estimate for very skewed distributions

Description

After fix for MDEV-5926, we see a regression for the filtered% column for testcase from MDEV-4350:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 create table t1 (a int); insert into t1 values (1), (1); insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 select * from t1; insert into t1 values (0); set use_stat_tables='preferably'; set histogram_size=127; set histogram_type='SINGLE_PREC_HB'; analyze table t1; flush table t1; set optimizer_use_condition_selectivity=4;
1 2 3 4 5 6 mysql> explain extended select * from t1 where a=0; +------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+ | 1 | SIMPLE | t1 | ALL | NULL | NULL | NULL | NULL | 1025 | 99.22 | Using where | +------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+

filtered% used to be 50%, now it's 99.22%. Both estimates are very wrong:

1 2 3 4 5 6 7 mysql> select a,count(*) from t1 group by a; +------+----------+ | a | count(*) | +------+----------+ | 0 | 1 | | 1 | 1024 | +------+----------+

But the new one is even worse than before.

Environment

None

Status

Assignee

Sergei Petrunia

Reporter

Sergei Petrunia

Labels

External issue ID

None

External issue ID

None

Fix versions

Affects versions

10.0.9

Priority

Major
Configure