Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0.9
-
None
Description
After fix for MDEV-5926, we see a regression for the filtered% column for testcase from MDEV-4350:
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;
|
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:
mysql> select a,count(*) from t1 group by a;
|
+------+----------+
|
| a | count(*) |
|
+------+----------+
|
| 0 | 1 |
|
| 1 | 1024 |
|
+------+----------+
|
But the new one is even worse than before.
Attachments
Issue Links
- relates to
-
MDEV-5926 EITS: Histogram estimates for column=least_possible_value are wrong
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Labels | eits |
Description |
After fix for {noformat} 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; {noformat} {noformat} 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 | +------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+ {noformat} |
After fix for {noformat} 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; {noformat} {noformat} 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 | +------+-------------+-------+------+---------------+------+---------+------+------+----------+-------------+ {noformat} filtered% used to be 50%, now it's 99.22%. Both estimates are very wrong: {noformat} mysql> select a,count(*) from t1 group by a; +------+----------+ | a | count(*) | +------+----------+ | 0 | 1 | | 1 | 1024 | +------+----------+ {noformat} But the new one is even worse than before. |
Assignee | Igor Babaev [ igor ] |
Assignee | Igor Babaev [ igor ] | Sergei Petrunia [ psergey ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Fix Version/s | 10.0.10 [ 14500 ] |
Resolution | Fixed [ 1 ] | |
Status | In Progress [ 3 ] | Closed [ 6 ] |
Workflow | defaullt [ 37401 ] | MariaDB v2 [ 42805 ] |
Workflow | MariaDB v2 [ 42805 ] | MariaDB v3 [ 62515 ] |
Workflow | MariaDB v3 [ 62515 ] | MariaDB v4 [ 147696 ] |
mysql> select *, hex(histogram) from mysql.column_stats where db_name='j32'\G
*************************** 1. row ***************************
db_name: j32
table_name: t1
column_name: a
min_value: 0
max_value: 1
nulls_ratio: 0.0000
avg_length: 4.0000
avg_frequency: 512.5000
hist_size: 127
hist_type: SINGLE_PREC_HB
histogram: �������������������������������������������������������������������������������������������������������������������������������
hex(histogram): FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
So, the histogram shows that all values are "1" (or very close to 1). We should be able to determine that value of 0 (which is equal to minimum) occupies zero buckets, not 99.22% of buckets.