mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed bug mdev-6325.
Field::selectivity should be set for all fields used in range conditions.
This commit is contained in:
@ -1356,6 +1356,41 @@ foo foo 1
|
||||
foo foo 2
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# Bug mdev-6325: wrong selectivity of a column with ref access
|
||||
#
|
||||
create table t0(a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t1(a int);
|
||||
insert into t1 select A.a + B.a* 10 + C.a * 100 from t0 A, t0 B, t0 C;
|
||||
create table t2 (a int, b int, key(a));
|
||||
insert into t2 select A.a + 10*B.a, 12345 from t0 A, t0 B, t0 C;
|
||||
set use_stat_tables='preferably';
|
||||
set histogram_size=100;
|
||||
set optimizer_use_condition_selectivity=4;
|
||||
analyze table t1 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
analyze table t2 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
explain extended
|
||||
select * from t1 straight_join t2 where t1.a=t2.a and t1.a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 0.99 Using where
|
||||
1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 10))
|
||||
explain extended
|
||||
select * from t1 straight_join t2 where t1.a=t2.a and t2.a<10;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 0.99 Using where
|
||||
1 SIMPLE t2 ref a a 5 test.t1.a 10 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`a` < 10))
|
||||
drop table t0,t1,t2;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
|
||||
set @tmp_ust= @@use_stat_tables;
|
||||
|
Reference in New Issue
Block a user