Commit cbd99688 authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-21095: Make Optimizer Trace support Index Condition Pushdown

Fixes over previous patches: do tracing of attached conditions
close to where we generate them.

Fix the tracing code to print the right conditions.
parent 07f21cfb
......@@ -177,23 +177,18 @@ select * from v1 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.a = 1"
}
]
"attached_condition": "t1.a = 1"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a = 1"
"make_join_readinfo": []
}
]
}
......@@ -353,23 +348,18 @@ select * from (select * from t1 where t1.a=1)q {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.a = 1"
}
]
"attached_condition": "t1.a = 1"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a = 1"
"make_join_readinfo": []
}
]
}
......@@ -536,13 +526,19 @@ select * from v2 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.a = 1"
"attached_condition": "t1.a = 1"
}
]
}
},
{
"make_join_readinfo": []
}
]
}
},
......@@ -614,17 +610,6 @@ select * from v2 {
"rows": 2,
"cost": 0.012418701
},
{
"make_join_readinfo": [
{
"table": "<derived2>",
"index_condition": null
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
......@@ -637,20 +622,15 @@ select * from v2 {
}
},
{
"join_execution": {
"select_id": 1,
"steps": [
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a = 1"
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
"steps": [
{
"join_execution": {
"select_id": 2,
......@@ -788,23 +768,18 @@ explain select * from v2 {
"cost": 0.01159965
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t2",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t2",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -931,13 +906,19 @@ explain select * from v1 {
"cost": 0.017968034
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
"attached_condition": null
}
]
}
},
{
"make_join_readinfo": []
}
]
}
},
......@@ -1009,17 +990,6 @@ explain select * from v1 {
"rows": 10,
"cost": 0.012757506
},
{
"make_join_readinfo": [
{
"table": "<derived2>",
"index_condition": null
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
......@@ -1032,20 +1002,15 @@ explain select * from v1 {
}
},
{
"join_execution": {
"select_id": 1,
"steps": [
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
"steps": [
{
"join_execution": {
"select_id": 2,
......@@ -1355,21 +1320,6 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
"resulting_condition": "t2.a = t1.b and t1.a = t2.b + 2"
}
},
{
"make_join_readinfo": [
{
"table": "t1",
"index_condition": "t1.b is not null"
},
{
"table": "t2",
"index_condition": "t1.a = t2.b + 2"
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
......@@ -1385,6 +1335,12 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
]
}
},
{
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
......@@ -1551,23 +1507,18 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"cost": 0.004191135
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -1780,12 +1731,18 @@ set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 wher
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.b = 2 and t1.c = 3"
"attached_condition": "t1.b = 2 and t1.c = 3"
}
]
}
},
{
"make_join_readinfo": []
},
{
"reconsidering_access_paths_for_index_ordering": {
......@@ -1812,17 +1769,6 @@ set statement optimizer_scan_setup_cost=0 for EXPLAIN SELECT MIN(d) FROM t1 wher
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.b = 2 and t1.c = 3"
}
]
}
},
{
"join_execution": {
"select_id": 1,
......@@ -2024,23 +1970,18 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.a >= 20010104e0"
}
]
"attached_condition": "t1.a >= 20010104e0"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a >= 20010104e0"
"make_join_readinfo": []
}
]
}
......@@ -2235,23 +2176,18 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.a = 20010104e0"
}
]
"attached_condition": "t1.a = 20010104e0"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a = 20010104e0"
"make_join_readinfo": []
}
]
}
......@@ -2542,12 +2478,18 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
"attached_condition": null
}
]
}
},
{
"make_join_readinfo": []
},
{
"reconsidering_access_paths_for_index_ordering": {
......@@ -2645,17 +2587,6 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a <=> 1 and t1.b <=> 2"
}
]
}
},
{
"join_execution": {
"select_id": 1,
......@@ -2819,28 +2750,24 @@ select t1.a from t1 left join t2 on t1.a=t2.a {
"resulting_condition": "1"
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [
{
"condition_on_constant_tables": "1",
"computing_condition": []
},
{
"make_join_readinfo": [
}
],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -3034,36 +2961,28 @@ explain select * from t1 left join t2 on t2.a=t1.a {
"resulting_condition": "t2.a = t1.a"
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [
{
"condition_on_constant_tables": "1",
"computing_condition": []
},
{
"make_join_readinfo": [
}
],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
"attached_condition": null
},
{
"table": "t2",
"index_condition": "trigcond(trigcond(t1.a is not null))"
}
]
"attached_condition": "trigcond(trigcond(t1.a is not null))"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
},
{
"table": "t2",
"attached_condition": "trigcond(trigcond(t1.a is not null))"
"make_join_readinfo": []
}
]
}
......@@ -3238,28 +3157,24 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and
"resulting_condition": "1"
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [
{
"condition_on_constant_tables": "1",
"computing_condition": []
},
{
"make_join_readinfo": [
}
],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -3641,27 +3556,12 @@ explain extended select * from t1 where a in (select p from t2) {
{
"best_join_order": ["t1", "t2"],
"rows": 4,
"cost": 0.074255053
},
{
"substitute_best_equal": {
"condition": "WHERE",
"resulting_condition": "t2.p = t1.a"
}
},
{
"make_join_readinfo": [
{
"table": "t1",
"index_condition": null
},
{
"table": "t2",
"index_condition": "t2.p = t1.a"
}
]
}
]
"cost": 0.074255053
},
{
"substitute_best_equal": {
"condition": "WHERE",
"resulting_condition": "t2.p = t1.a"
}
},
{
......@@ -3679,6 +3579,12 @@ explain extended select * from t1 where a in (select p from t2) {
]
}
},
{
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
......@@ -4038,23 +3944,18 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -4184,23 +4085,18 @@ select f1(a) from t1 {
"cost": 0.01066122
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -4306,23 +4202,18 @@ select f2(a) from t1 {
"cost": 0.01066122
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -4352,7 +4243,7 @@ a
2
select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
length(trace)
2869
2819
set optimizer_trace_max_mem_size=100;
select * from t1;
a
......@@ -4366,7 +4257,7 @@ select * from t1 {
"join_preparation": {
"select_id": 1,
"steps": [
2769 0
2719 0
set optimizer_trace_max_mem_size=0;
select * from t1;
a
......@@ -4374,7 +4265,7 @@ a
2
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
select * from t1 2869 0
select * from t1 2819 0
drop table t1;
set optimizer_trace='enabled=off';
set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size;
......@@ -4842,21 +4733,6 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
"resulting_condition": "t1.a = t0.a and t0.a < 3"
}
},
{
"make_join_readinfo": [
{
"table": "t0",
"index_condition": "t0.a < 3 and t0.a is not null"
},
{
"table": "t1",
"index_condition": null
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
......@@ -4872,6 +4748,12 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
]
}
},
{
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
......@@ -5008,13 +4890,19 @@ explain select * from (select rand() from t1)q {
"cost": 0.010504815
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
"attached_condition": null
}
]
}
},
{
"make_join_readinfo": []
}
]
}
},
......@@ -5086,17 +4974,6 @@ explain select * from (select rand() from t1)q {
"rows": 3,
"cost": 0.012461052
},
{
"make_join_readinfo": [
{
"table": "<derived2>",
"index_condition": null
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
......@@ -5109,20 +4986,15 @@ explain select * from (select rand() from t1)q {
}
},
{
"join_execution": {
"select_id": 1,
"steps": [
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
"steps": [
{
"join_execution": {
"select_id": 2,
......@@ -5679,36 +5551,14 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"resulting_condition": "1"
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [
{
"condition_on_constant_tables": "1",
"computing_condition": []
},
{
"make_join_readinfo": [
{
"table": "t1",
"index_condition": null
},
{
"table": "<subquery2>",
"index_condition": "t1.a = `sj-materialize`.a"
},
{
"table": "t_inner_1",
"index_condition": null
},
{
"table": "t_inner_2",
"index_condition": null
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
],
"attached_conditions_summary": [
{
"table": "t1",
......@@ -5724,7 +5574,13 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
},
{
"table": "<subquery2>",
"attached_condition": "t1.a = `sj-materialize`.a"
"attached_condition": null
}
]
}
},
{
"make_join_readinfo": []
}
]
}
......@@ -8054,37 +7910,6 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"resulting_condition": "t_inner_1.a = t_outer_1.a and t_inner_3.a = t_outer_2.a"
}
},
{
"make_join_readinfo": [
{
"table": "t_outer_1",
"index_condition": null
},
{
"table": "t_inner_1",
"index_condition": "t_inner_1.a = t_outer_1.a"
},
{
"table": "t_inner_2",
"index_condition": null
},
{
"table": "t_inner_4",
"index_condition": null
},
{
"table": "t_outer_2",
"index_condition": null
},
{
"table": "t_inner_3",
"index_condition": "t_inner_3.a = t_outer_2.a"
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
......@@ -8116,6 +7941,12 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
]
}
},
{
"make_join_readinfo": []
}
]
}
},
{
"join_execution": {
"select_id": 1,
......@@ -10455,52 +10286,14 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"resulting_condition": "1"
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [
{
"condition_on_constant_tables": "1",
"computing_condition": []
},
{
"make_join_readinfo": [
{
"table": "t_outer_1",
"index_condition": null
},
{
"table": "<subquery2>",
"index_condition": "t_outer_1.a = `sj-materialize`.a"
},
{
"table": "t_inner_1",
"index_condition": null
},
{
"table": "t_inner_2",
"index_condition": null
},
{
"table": "t_outer_2",
"index_condition": null
},
{
"table": "<subquery3>",
"index_condition": "t_outer_2.a = `sj-materialize`.a"
},
{
"table": "t_inner_4",
"index_condition": null
},
{
"table": "t_inner_3",
"index_condition": null
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
],
"attached_conditions_summary": [
{
"table": "t_outer_1",
......@@ -10516,7 +10309,7 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
},
{
"table": "<subquery2>",
"attached_condition": "t_outer_1.a = `sj-materialize`.a"
"attached_condition": null
},
{
"table": "t_outer_2",
......@@ -10532,7 +10325,13 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
},
{
"table": "<subquery3>",
"attached_condition": "t_outer_2.a = `sj-materialize`.a"
"attached_condition": null
}
]
}
},
{
"make_join_readinfo": []
}
]
}
......@@ -11762,12 +11561,6 @@ SELECT 'a\0' LIMIT 0 {
"steps": []
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": []
}
},
{
"join_execution": {
"select_id": 1,
......@@ -11883,23 +11676,18 @@ select count(*) from seq_1_to_10000000 {
"cost": 444.7880673
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "seq_1_to_10000000",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "seq_1_to_10000000",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -12637,24 +12425,24 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.b between 10 and 50 and t1.c < 10"
}
]
"attached_condition": "t1.a < 10 and t1.b between 10 and 50 and t1.c < 10"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
"make_join_readinfo": [
{
"table": "t1",
"attached_condition": "t1.b between 10 and 50 and t1.c < 10",
"index_condition": "t1.a < 10"
"index_condition": "t1.a < 10",
"row_condition": "t1.b between 10 and 50 and t1.c < 10"
}
]
}
]
}
......@@ -13057,6 +12845,9 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"resulting_condition": "t1.a = three.a and t1.b < 5000 and t1.c < 1000"
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [
{
"table": "t1",
"range_analysis": {
......@@ -13104,33 +12895,22 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
"cause": "not single_table"
}
}
},
{
"make_join_readinfo": [
}
],
"attached_conditions_summary": [
{
"table": "three",
"index_condition": null
"attached_condition": null
},
{
"table": "t1",
"index_condition": "t1.a = three.a and t1.b < 5000 and t1.c < 1000"
"attached_condition": "t1.a = three.a and t1.b < 5000 and t1.c < 1000"
}
]
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "three",
"attached_condition": null
},
{
"table": "t1",
"attached_condition": "t1.a = three.a"
"make_join_readinfo": []
}
]
}
......@@ -13190,8 +12970,7 @@ out1
[
{
"table": "t10",
"attached_condition": "t10.c < 10",
"index_condition": "t10.a < 3 and t10.b <> 5"
"attached_condition": "t10.a < 3 and t10.b <> 5 and t10.c < 10"
}
]
}
......
......@@ -257,23 +257,18 @@ explain select * from t1 where a=1 or b=1 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": "t1.a = 1 or t1.b = 1"
}
]
"attached_condition": "t1.a = 1 or t1.b = 1"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": "t1.a = 1 or t1.b = 1"
"make_join_readinfo": []
}
]
}
......
......@@ -256,27 +256,26 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
}
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": "t1.pk1 <> 0"
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
"make_join_readinfo": [
{
"table": "t1",
"attached_condition": null,
"index_condition": "t1.pk1 <> 0"
}
]
}
]
}
},
{
"join_execution": {
......
......@@ -133,23 +133,18 @@ select * from db1.t1 {
"cost": 0.010504815
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......@@ -280,23 +275,18 @@ select * from db1.v1 {
"cost": 0.010504815
},
{
"make_join_readinfo": [
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"index_condition": null
}
]
"attached_condition": null
}
]
}
},
{
"attaching_conditions_to_tables": {
"attached_conditions_computation": [],
"attached_conditions_summary": [
{
"table": "t1",
"attached_condition": null
"make_join_readinfo": []
}
]
}
......
......@@ -17,6 +17,7 @@
#include "mariadb.h"
#include "sql_select.h"
#include "sql_test.h"
#include "opt_trace.h"
/****************************************************************************
* Index Condition Pushdown code starts
......@@ -355,6 +356,8 @@ void push_index_cond(JOIN_TAB *tab, uint keyno)
{
Item *idx_remainder_cond= 0;
tab->pre_idx_push_select_cond= tab->select_cond;
Json_writer_object trace(tab->join->thd);
trace.add_table_name(tab);
/*
For BKA cache we store condition to special BKA cache field
because evaluation of the condition requires additional operations
......@@ -387,6 +390,7 @@ void push_index_cond(JOIN_TAB *tab, uint keyno)
idx_remainder_cond= NULL;
}
}
trace.add("index_condition", idx_cond);
/*
Disable eq_ref's "lookup cache" if we've pushed down an index
......@@ -424,6 +428,10 @@ void push_index_cond(JOIN_TAB *tab, uint keyno)
}
else
tab->select_cond= idx_remainder_cond;
if (tab->select_cond)
trace.add("row_condition", tab->select_cond);
if (tab->select)
{
DBUG_EXECUTE("where",
......
......@@ -349,8 +349,6 @@ static void fix_items_after_optimize(THD *thd, SELECT_LEX *select_lex);
static void optimize_rownum(THD *thd, SELECT_LEX_UNIT *unit, Item *cond);
static bool process_direct_rownum_comparison(THD *thd, SELECT_LEX_UNIT *unit,
Item *cond);
void trace_attached_conditions(THD *thd, JOIN *join);
void trace_join_readinfo(THD *thd, JOIN *join);
#ifndef DBUG_OFF
......@@ -3139,8 +3137,6 @@ int JOIN::optimize_stage2()
if (make_join_readinfo(this, select_opts_for_readinfo, no_jbuf_after))
DBUG_RETURN(1);
trace_join_readinfo(thd, this);
/* Perform FULLTEXT search before all regular searches */
if (!(select_options & SELECT_DESCRIBE))
if (init_ftfuncs(thd, select_lex, MY_TEST(order)))
......@@ -5116,8 +5112,6 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
goto err; // 1
}
trace_attached_conditions(thd, join);
if (thd->lex->describe & DESCRIBE_EXTENDED)
{
join->conds_history= join->conds;
......@@ -12980,6 +12974,10 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
DBUG_ENTER("make_join_select");
if (select)
{
Json_writer_object trace_wrapper(thd);
Json_writer_object trace_conditions(thd, "attaching_conditions_to_tables");
Json_writer_array trace_attached_comp(thd,
"attached_conditions_computation");
add_not_null_conds(join);
table_map used_tables;
/*
......@@ -13056,6 +13054,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
{
add_cond_and_fix(thd, &outer_ref_cond, join->outer_ref_cond);
join->outer_ref_cond= outer_ref_cond;
Json_writer_object trace(thd);
trace.add("outer_ref_cond", outer_ref_cond);
}
}
else
......@@ -13071,6 +13072,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
add_cond_and_fix(thd, &pseudo_bits_cond,
join->pseudo_bits_cond);
join->pseudo_bits_cond= pseudo_bits_cond;
Json_writer_object trace(thd);
trace.add("pseudo_bits_cond", pseudo_bits_cond);
}
}
}
......@@ -13647,6 +13651,22 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
i++;
}
if (unlikely(thd->trace_started()))
{
trace_attached_comp.end();
Json_writer_array trace_attached_summary(thd,
"attached_conditions_summary");
for (tab= first_depth_first_tab(join); tab;
tab= next_depth_first_tab(join, tab))
{
if (!tab->table)
continue;
Item *const cond = tab->select_cond;
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(tab);
trace_one_table.add("attached_condition", cond);
}
}
}
DBUG_RETURN(0);
}
......@@ -14724,6 +14744,9 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
uint i;
DBUG_ENTER("make_join_readinfo");
Json_writer_object trace_wrapper(join->thd);
Json_writer_array trace_arr(join->thd, "make_join_readinfo");
bool statistics= MY_TEST(!(join->select_options & SELECT_DESCRIBE));
bool sorted= 1;
......@@ -31905,61 +31928,6 @@ bool JOIN::transform_all_conds_and_on_exprs_in_join_list(
return false;
}
void trace_attached_conditions(THD *thd, JOIN *join)
{
if (!unlikely(thd->trace_started()))
return;
Json_writer_object trace_wrapper(thd);
Json_writer_object trace_conditions(thd, "attaching_conditions_to_tables");
Json_writer_array trace_attached_comp(thd,
"attached_conditions_computation");
JOIN_TAB *tab;
trace_attached_comp.end();
Json_writer_array trace_attached_summary(thd,
"attached_conditions_summary");
for (tab= first_depth_first_tab(join);
tab;
tab= next_depth_first_tab(join, tab))
{
if (!tab->table)
continue;
Item *const remaining_cond = tab->select_cond;
Item *const idx_cond = tab->table->file->pushed_idx_cond;
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(tab);
trace_one_table.add("attached_condition", remaining_cond);
if (idx_cond)
trace_one_table.add("index_condition", idx_cond);
}
}
void trace_join_readinfo(THD *thd, JOIN *join)
{
if (!unlikely(thd->trace_started()))
return;
Json_writer_object trace_wrapper(thd);
Json_writer_array trace_conditions(thd, "make_join_readinfo");
JOIN_TAB *tab;
for (tab= first_linear_tab(join, WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES);
tab;
tab= next_linear_tab(join, tab, WITH_BUSH_ROOTS))
{
Json_writer_object trace_one_table(thd);
trace_one_table.add_table_name(tab);
trace_one_table.add("index_condition", tab->select_cond);
}
}
/**
@} (end of group Query_Optimizer)
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment