1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

EXPLAIN FORMAT=JSON

Add support for semi-join strategies: FirstMatch, DuplicateWeedout,
LooseScan.
This commit is contained in:
Sergei Petrunia
2014-12-02 01:40:10 +03:00
parent a35b05399e
commit 0000695025
5 changed files with 123 additions and 3 deletions

View File

@ -592,5 +592,77 @@ EXPLAIN
}
}
}
#
# First-Match
#
explain
select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; FirstMatch(t2); Using join buffer (flat, BNL join)
explain format=json
select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b);
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": 10,
"filtered": 100
},
"block-nl-join": {
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 10,
"filtered": 100,
"first_match": "t2"
},
"buffer_type": "flat",
"join_type": "BNL",
"attached_condition": "((t1.b = t2.b) and (t1.a = t2.a))"
}
}
}
#
# Duplicate Weedout
#
set @tmp= @@optimizer_switch;
set optimizer_switch='firstmatch=off';
explain
select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 10
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where; Start temporary; End temporary; Using join buffer (flat, BNL join)
explain format=json
select * from t2 where t2.a in ( select a from t1 where t1.b=t2.b);
EXPLAIN
{
"query_block": {
"select_id": 1,
"table": {
"table_name": "t2",
"access_type": "ALL",
"rows": 10,
"filtered": 100
},
"duplicates_removal": {
"block-nl-join": {
"table": {
"table_name": "t1",
"access_type": "ALL",
"rows": 10,
"filtered": 100
},
"buffer_type": "flat",
"join_type": "BNL",
"attached_condition": "((t1.b = t2.b) and (t1.a = t2.a))"
}
}
}
}
set optimizer_switch=@tmp;
drop table t1,t2;
drop table t0;