mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
MDEV-20109: Optimizer ignores distinct key created for materialized...
(Backported to 10.3, addressed review input) Sj_materialization_picker::check_qep(): fix error in cost/fanout calculations: - for each join prefix, add #prefix_rows / TIME_FOR_COMPARE to the cost, like best_extension_by_limited_search does - Remove the fanout produced by the subquery tables. - Also take into account join condition selectivity optimize_wo_join_buffering() (used by LooseScan and FirstMatch) - also add #prefix_rows / TIME_FOR_COMPARE to the cost of each prefix. - Also take into account join condition selectivity
This commit is contained in:
parent
d58437d195
commit
ef76f81c98
27 changed files with 392 additions and 295 deletions
|
|
@ -1149,8 +1149,8 @@ create table t3 (a int);
|
|||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
create table t4 (pk int primary key);
|
||||
insert into t4 select a from t3;
|
||||
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
|
||||
|
|
@ -1286,12 +1286,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
|
|||
create table t2 as select * from t1;
|
||||
explain select * from t2 where a in (select b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 8 Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref a a 10 const,test.t2.a 1 Using index; FirstMatch(t2)
|
||||
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 8 Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref a a 10 const,test.t2.a 1 Using index; FirstMatch(t2)
|
||||
drop table t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
create table t1 (a int, b int);
|
||||
|
|
@ -1348,10 +1348,10 @@ create table t2 as select a as a, a as b from t0 where a < 3;
|
|||
insert into t2 select * from t2;
|
||||
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where; Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1); Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY X hash_ALL NULL #hash#$hj 5 test.t1.a 6 Using where; Start temporary; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY Y hash_ALL NULL #hash#$hj 5 test.t1.b 6 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 PRIMARY Z hash_ALL NULL #hash#$hj 5 test.t1.c 6 Using where; End temporary; Using join buffer (incremental, BNLH join)
|
||||
drop table t0,t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue