summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRex <rex.johnston@mariadb.com>2022-12-02 16:46:54 +1200
committerSergei Petrunia <sergey@mariadb.com>2023-02-03 14:28:08 +0300
commit07f21cfb146f7dab3c999fc2dee47b7e7f3b459d (patch)
treef9dfbb4d95f48613bf1a02a295a010ca3429861f
parentdba78f3c32274a5fac29250416568998a65c7622 (diff)
downloadmariadb-git-07f21cfb146f7dab3c999fc2dee47b7e7f3b459d.tar.gz
MDEV-21092,MDEV-21095,MDEV-29997: Optimizer Trace for index condition pushdown, partition pruning, exists-to-in
Add Optimizer Tracing for: - Index Condition Pushdown - Partition Pruning - Exists-to-IN optimization
-rw-r--r--mysql-test/main/opt_trace.result1215
-rw-r--r--mysql-test/main/opt_trace.test57
-rw-r--r--mysql-test/main/opt_trace_index_merge.result26
-rw-r--r--mysql-test/main/opt_trace_index_merge_innodb.result27
-rw-r--r--mysql-test/main/opt_trace_security.result52
-rw-r--r--sql/item.cc24
-rw-r--r--sql/item_subselect.cc9
-rw-r--r--sql/opt_range.cc14
-rw-r--r--sql/sql_select.cc84
9 files changed, 1062 insertions, 446 deletions
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result
index 2945e57bd68..c14b21e7d0f 100644
--- a/mysql-test/main/opt_trace.result
+++ b/mysql-test/main/opt_trace.result
@@ -177,15 +177,23 @@ select * from v1 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a = 1"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.a = 1"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.a = 1"
}
]
}
@@ -345,15 +353,23 @@ select * from (select * from t1 where t1.a=1)q {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a = 1"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.a = 1"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.a = 1"
}
]
}
@@ -520,15 +536,12 @@ select * from v2 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a = 1"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.a = 1"
+ }
+ ]
}
]
}
@@ -602,15 +615,23 @@ select * from v2 {
"cost": 0.012418701
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "<derived2>",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "<derived2>",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "<derived2>",
+ "attached_condition": null
}
]
}
@@ -620,6 +641,17 @@ select * from v2 {
"select_id": 1,
"steps": [
{
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.a = 1"
+ }
+ ]
+ }
+ },
+ {
"join_execution": {
"select_id": 2,
"steps": []
@@ -756,15 +788,23 @@ explain select * from v2 {
"cost": 0.01159965
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t2",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t2",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t2",
+ "attached_condition": null
}
]
}
@@ -891,15 +931,12 @@ explain select * from v1 {
"cost": 0.017968034
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
}
]
}
@@ -973,15 +1010,23 @@ explain select * from v1 {
"cost": 0.012757506
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "<derived2>",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "<derived2>",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "<derived2>",
+ "attached_condition": null
}
]
}
@@ -991,6 +1036,17 @@ explain select * from v1 {
"select_id": 1,
"steps": [
{
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
+ }
+ ]
+ }
+ },
+ {
"join_execution": {
"select_id": 2,
"steps": []
@@ -1300,19 +1356,31 @@ explain select * from t1,t2 where t1.a=t2.b+2 and t2.a= t1.b {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.b is not null"
- },
- {
- "table": "t2",
- "attached": "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": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.b is not null"
+ },
+ {
+ "table": "t2",
+ "attached_condition": "t1.a = t2.b + 2"
}
]
}
@@ -1483,15 +1551,23 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
"cost": 0.004191135
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -1704,15 +1780,12 @@ 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": "t1.b = 2 and t1.c = 3"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.b = 2 and t1.c = 3"
+ }
+ ]
},
{
"reconsidering_access_paths_for_index_ordering": {
@@ -1740,6 +1813,17 @@ 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,
"steps": []
@@ -1940,15 +2024,23 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a >= 20010104e0"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.a >= 20010104e0"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.a >= 20010104e0"
}
]
}
@@ -2143,15 +2235,23 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a = 20010104e0"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.a = 20010104e0"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.a = 20010104e0"
}
]
}
@@ -2442,15 +2542,12 @@ 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": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
},
{
"reconsidering_access_paths_for_index_ordering": {
@@ -2549,6 +2646,17 @@ 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,
"steps": []
@@ -2716,15 +2824,23 @@ select t1.a from t1 left join t2 on t1.a=t2.a {
"computing_condition": []
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -2923,19 +3039,31 @@ explain select * from t1 left join t2 on t2.a=t1.a {
"computing_condition": []
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- },
- {
- "table": "t2",
- "attached": "trigcond(trigcond(t1.a is not null))"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ },
+ {
+ "table": "t2",
+ "index_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))"
}
]
}
@@ -3115,15 +3243,23 @@ explain select t1.a from t1 left join (t2 join t3 on t2.b=t3.b) on t2.a=t1.a and
"computing_condition": []
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -3514,19 +3650,31 @@ explain extended select * from t1 where a in (select p from t2) {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- },
- {
- "table": "t2",
- "attached": "t2.p = t1.a"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ },
+ {
+ "table": "t2",
+ "index_condition": "t2.p = t1.a"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
+ },
+ {
+ "table": "t2",
+ "attached_condition": "t2.p = t1.a"
}
]
}
@@ -3890,15 +4038,23 @@ explain select * from t1 where pk = 2 and a=5 and b=1 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -4028,15 +4184,23 @@ select f1(a) from t1 {
"cost": 0.01066122
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -4142,15 +4306,23 @@ select f2(a) from t1 {
"cost": 0.01066122
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -4180,7 +4352,7 @@ a
2
select length(trace) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
length(trace)
-2747
+2869
set optimizer_trace_max_mem_size=100;
select * from t1;
a
@@ -4194,7 +4366,7 @@ select * from t1 {
"join_preparation": {
"select_id": 1,
"steps": [
- 2647 0
+ 2769 0
set optimizer_trace_max_mem_size=0;
select * from t1;
a
@@ -4202,7 +4374,7 @@ a
2
select * from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES
-select * from t1 2747 0
+select * from t1 2869 0
drop table t1;
set optimizer_trace='enabled=off';
set @@optimizer_trace_max_mem_size= @save_optimizer_trace_max_mem_size;
@@ -4671,19 +4843,31 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t0",
- "attached": "t0.a < 3 and t0.a is not null"
- },
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "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": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t0",
+ "attached_condition": "t0.a < 3 and t0.a is not null"
+ },
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -4824,15 +5008,12 @@ explain select * from (select rand() from t1)q {
"cost": 0.010504815
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
}
]
}
@@ -4906,15 +5087,23 @@ explain select * from (select rand() from t1)q {
"cost": 0.012461052
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "<derived2>",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "<derived2>",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "<derived2>",
+ "attached_condition": null
}
]
}
@@ -4924,6 +5113,17 @@ explain select * from (select rand() from t1)q {
"select_id": 1,
"steps": [
{
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
+ }
+ ]
+ }
+ },
+ {
"join_execution": {
"select_id": 2,
"steps": []
@@ -5484,27 +5684,47 @@ explain select * from t1 where a in (select t_inner_1.a from t1 t_inner_1, t1 t_
"computing_condition": []
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- },
- {
- "table": "t_inner_1",
- "attached": null
- },
- {
- "table": "t_inner_2",
- "attached": null
- },
- {
- "table": "<subquery2>",
- "attached": null
- }
- ]
- }
+ "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",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_1",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_2",
+ "attached_condition": null
+ },
+ {
+ "table": "<subquery2>",
+ "attached_condition": "t1.a = `sj-materialize`.a"
}
]
}
@@ -7835,35 +8055,63 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t_outer_1",
- "attached": null
- },
- {
- "table": "t_inner_1",
- "attached": "t_inner_1.a = t_outer_1.a"
- },
- {
- "table": "t_inner_2",
- "attached": null
- },
- {
- "table": "t_inner_4",
- "attached": null
- },
- {
- "table": "t_outer_2",
- "attached": null
- },
- {
- "table": "t_inner_3",
- "attached": "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": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t_outer_1",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_1",
+ "attached_condition": "t_inner_1.a = t_outer_1.a"
+ },
+ {
+ "table": "t_inner_2",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_4",
+ "attached_condition": null
+ },
+ {
+ "table": "t_outer_2",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_3",
+ "attached_condition": "t_inner_3.a = t_outer_2.a"
}
]
}
@@ -10212,43 +10460,79 @@ t_outer_2.a in (select t_inner_3.a from t2 t_inner_3, t1 t_inner_4) {
"computing_condition": []
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t_outer_1",
- "attached": null
- },
- {
- "table": "t_inner_1",
- "attached": null
- },
- {
- "table": "t_inner_2",
- "attached": null
- },
- {
- "table": "<subquery2>",
- "attached": null
- },
- {
- "table": "t_outer_2",
- "attached": null
- },
- {
- "table": "t_inner_4",
- "attached": null
- },
- {
- "table": "t_inner_3",
- "attached": null
- },
- {
- "table": "<subquery3>",
- "attached": null
- }
- ]
- }
+ "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",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_1",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_2",
+ "attached_condition": null
+ },
+ {
+ "table": "<subquery2>",
+ "attached_condition": "t_outer_1.a = `sj-materialize`.a"
+ },
+ {
+ "table": "t_outer_2",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_4",
+ "attached_condition": null
+ },
+ {
+ "table": "t_inner_3",
+ "attached_condition": null
+ },
+ {
+ "table": "<subquery3>",
+ "attached_condition": "t_outer_2.a = `sj-materialize`.a"
}
]
}
@@ -11479,6 +11763,12 @@ SELECT 'a\0' LIMIT 0 {
}
},
{
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": []
+ }
+ },
+ {
"join_execution": {
"select_id": 1,
"steps": []
@@ -11593,15 +11883,23 @@ select count(*) from seq_1_to_10000000 {
"cost": 444.7880673
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "seq_1_to_10000000",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "seq_1_to_10000000",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "seq_1_to_10000000",
+ "attached_condition": null
}
]
}
@@ -12339,15 +12637,24 @@ explain select * from t1 where a<10 and b between 10 and 50 and c < 10 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a < 10 and t1.b between 10 and 50 and t1.c < 10"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": "t1.b between 10 and 50 and t1.c < 10"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": "t1.b between 10 and 50 and t1.c < 10",
+ "index_condition": "t1.a < 10"
}
]
}
@@ -12751,68 +13058,79 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [
- {
- "table": "t1",
- "range_analysis": {
- "table_scan": {
- "rows": 10000,
- "cost": 1.581538
- },
- "potential_range_indexes": [
- {
- "index": "a",
- "usable": true,
- "key_parts": ["a"]
- },
- {
- "index": "b",
- "usable": true,
- "key_parts": ["b"]
- }
- ],
- "setup_range_conditions": [],
- "analyzing_range_alternatives": {
- "range_scan_alternatives": [
- {
- "index": "a"
- },
- {
- "index": "b",
- "ranges": ["(NULL) < (b) < (5000)"],
- "rowid_ordered": false,
- "using_mrr": false,
- "index_only": false,
- "rows": 4312,
- "cost": 5.325058827,
- "chosen": false,
- "cause": "cost"
- }
- ],
- "analyzing_roworder_intersect": {
- "cause": "too few roworder scans"
- },
- "analyzing_index_merge_union": []
- },
- "group_index_range": {
- "chosen": false,
- "cause": "not single_table"
- }
- }
- }
- ],
- "attached_conditions_summary": [
+ "table": "t1",
+ "range_analysis": {
+ "table_scan": {
+ "rows": 10000,
+ "cost": 1.581538
+ },
+ "potential_range_indexes": [
{
- "table": "three",
- "attached": null
+ "index": "a",
+ "usable": true,
+ "key_parts": ["a"]
},
{
- "table": "t1",
- "attached": "t1.a = three.a and t1.b < 5000 and t1.c < 1000"
+ "index": "b",
+ "usable": true,
+ "key_parts": ["b"]
}
- ]
+ ],
+ "setup_range_conditions": [],
+ "analyzing_range_alternatives": {
+ "range_scan_alternatives": [
+ {
+ "index": "a"
+ },
+ {
+ "index": "b",
+ "ranges": ["(NULL) < (b) < (5000)"],
+ "rowid_ordered": false,
+ "using_mrr": false,
+ "index_only": false,
+ "rows": 4312,
+ "cost": 5.325058827,
+ "chosen": false,
+ "cause": "cost"
+ }
+ ],
+ "analyzing_roworder_intersect": {
+ "cause": "too few roworder scans"
+ },
+ "analyzing_index_merge_union": []
+ },
+ "group_index_range": {
+ "chosen": false,
+ "cause": "not single_table"
+ }
}
+ },
+ {
+ "make_join_readinfo": [
+ {
+ "table": "three",
+ "index_condition": null
+ },
+ {
+ "table": "t1",
+ "index_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"
}
]
}
@@ -12826,6 +13144,127 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
]
} 0 0
drop table three, t1;
+#
+# MDEV-21095: Index condition push down is not reflected in optimizer trace
+#
+create table t10 (a int, b int, c int, key(a,b));
+insert into t10 select seq, seq, seq from seq_1_to_10000;
+explain format=json select * from t10 where a<3 and b!=5 and c<10;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "cost": 0.003717837,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t10",
+ "access_type": "range",
+ "possible_keys": ["a"],
+ "key": "a",
+ "key_length": "5",
+ "used_key_parts": ["a"],
+ "loops": 1,
+ "rows": 2,
+ "cost": 0.003717837,
+ "filtered": 100,
+ "index_condition": "t10.a < 3 and t10.b <> 5",
+ "attached_condition": "t10.c < 10"
+ }
+ }
+ ]
+ }
+}
+set optimizer_trace='enabled=on';
+select * from t10 where a<3 and b!=5 and c<10;
+a b c
+1 1 1
+2 2 2
+select json_detailed(json_extract(trace, '$**.attaching_conditions_to_tables')) as out1 from information_schema.optimizer_trace;
+out1
+[
+ {
+ "attached_conditions_computation":
+ [],
+ "attached_conditions_summary":
+ [
+ {
+ "table": "t10",
+ "attached_condition": "t10.c < 10",
+ "index_condition": "t10.a < 3 and t10.b <> 5"
+ }
+ ]
+ }
+]
+drop table t10;
+#
+# MDEV-21092: EXISTS to IN is not reflected in the optimizer trace
+#
+set @@optimizer_switch = 'exists_to_in=on,in_to_exists=on,semijoin=on,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on';
+set optimizer_trace='enabled=on';
+create table t1 (cn_c int, cn_n char(10), cn_a int );
+create table t2 (ci_p int, ci_c int );
+create table t3 (ci_p int, ci_c int );
+SELECT cn_n FROM t1 WHERE (EXISTS (select 1 from t2 where ci_p > 100000 and cn_c = ci_c)
+OR (cn_n LIKE 'L%') )
+AND cn_a > 1000000;
+cn_n
+select json_detailed(json_extract(trace, '$.steps[*].join_optimization[0].steps[0].transformation')) from information_schema.optimizer_trace;
+json_detailed(json_extract(trace, '$.steps[*].join_optimization[0].steps[0].transformation'))
+[
+ {
+ "select_id": 2,
+ "from": "EXISTS (SELECT)",
+ "to": "IN (SELECT)",
+ "upper_not": false
+ }
+]
+drop table t1, t2, t3;
+#
+# MDEV-29997 Partition Pruning not included in optimizer tracing
+#
+create table t2 (a int, b int) partition by hash(a) partitions 10;
+create table t3 (a int, b int) partition by hash(a) partitions 10;
+INSERT INTO t2 SELECT seq, seq from seq_1_to_10;
+INSERT INTO t3 SELECT seq, seq from seq_1_to_10;
+set optimizer_trace='enabled=on';
+explain partitions select * from t2,t3 where t2.a in (2,3,4) and t3.a in (4,5);
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 p4,p5 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t2 p2,p3,p4 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+select json_detailed(json_extract(trace, '$**.prune_partitions')) from information_schema.optimizer_trace;
+json_detailed(json_extract(trace, '$**.prune_partitions'))
+[
+ {
+ "table": "t2",
+ "used_partitions": "p2,p3,p4"
+ },
+ {
+ "table": "t3",
+ "used_partitions": "p4,p5"
+ }
+]
+drop table t2,t3;
+create table t1 (
+a int
+) partition by range (a)
+( partition p0 values less than(10),
+partition p1 values less than (20),
+partition p2 values less than (25)
+);
+insert into t1 values (5),(15),(22);
+explain select * from t1 where a = 28;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select json_detailed(json_extract(trace, '$**.prune_partitions')) from information_schema.optimizer_trace;
+json_detailed(json_extract(trace, '$**.prune_partitions'))
+[
+ {
+ "table": "t1",
+ "used_partitions": ""
+ }
+]
+drop table t1;
set @@optimizer_switch= @save_optimizer_switch;
set @@use_stat_tables= @save_use_stat_tables;
set @@histogram_size= @save_histogram_size;
diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test
index 29da64616de..a63119e7e6d 100644
--- a/mysql-test/main/opt_trace.test
+++ b/mysql-test/main/opt_trace.test
@@ -932,7 +932,64 @@ explain format=json select * from three, t1 where t1.a=three.a and t1.b<5000 and
drop table three, t1;
+--echo #
+--echo # MDEV-21095: Index condition push down is not reflected in optimizer trace
+--echo #
+create table t10 (a int, b int, c int, key(a,b));
+insert into t10 select seq, seq, seq from seq_1_to_10000;
+explain format=json select * from t10 where a<3 and b!=5 and c<10;
+set optimizer_trace='enabled=on';
+select * from t10 where a<3 and b!=5 and c<10;
+select json_detailed(json_extract(trace, '$**.attaching_conditions_to_tables')) as out1 from information_schema.optimizer_trace;
+drop table t10;
+
+--echo #
+--echo # MDEV-21092: EXISTS to IN is not reflected in the optimizer trace
+--echo #
+set @@optimizer_switch = 'exists_to_in=on,in_to_exists=on,semijoin=on,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on';
+set optimizer_trace='enabled=on';
+
+create table t1 (cn_c int, cn_n char(10), cn_a int );
+create table t2 (ci_p int, ci_c int );
+create table t3 (ci_p int, ci_c int );
+
+SELECT cn_n FROM t1 WHERE (EXISTS (select 1 from t2 where ci_p > 100000 and cn_c = ci_c)
+ OR (cn_n LIKE 'L%') )
+ AND cn_a > 1000000;
+
+select json_detailed(json_extract(trace, '$.steps[*].join_optimization[0].steps[0].transformation')) from information_schema.optimizer_trace;
+
+drop table t1, t2, t3;
+
+--echo #
+--echo # MDEV-29997 Partition Pruning not included in optimizer tracing
+--echo #
+--source include/have_partition.inc
+create table t2 (a int, b int) partition by hash(a) partitions 10;
+create table t3 (a int, b int) partition by hash(a) partitions 10;
+INSERT INTO t2 SELECT seq, seq from seq_1_to_10;
+INSERT INTO t3 SELECT seq, seq from seq_1_to_10;
+
+set optimizer_trace='enabled=on';
+explain partitions select * from t2,t3 where t2.a in (2,3,4) and t3.a in (4,5);
+select json_detailed(json_extract(trace, '$**.prune_partitions')) from information_schema.optimizer_trace;
+drop table t2,t3;
+
+create table t1 (
+ a int
+) partition by range (a)
+( partition p0 values less than(10),
+ partition p1 values less than (20),
+ partition p2 values less than (25)
+);
+insert into t1 values (5),(15),(22);
+
+explain select * from t1 where a = 28;
+select json_detailed(json_extract(trace, '$**.prune_partitions')) from information_schema.optimizer_trace;
+drop table t1;
+
set @@optimizer_switch= @save_optimizer_switch;
set @@use_stat_tables= @save_use_stat_tables;
set @@histogram_size= @save_histogram_size;
set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+
diff --git a/mysql-test/main/opt_trace_index_merge.result b/mysql-test/main/opt_trace_index_merge.result
index 1970511a401..0902c7a2603 100644
--- a/mysql-test/main/opt_trace_index_merge.result
+++ b/mysql-test/main/opt_trace_index_merge.result
@@ -257,15 +257,23 @@ explain select * from t1 where a=1 or b=1 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.a = 1 or t1.b = 1"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_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"
}
]
}
diff --git a/mysql-test/main/opt_trace_index_merge_innodb.result b/mysql-test/main/opt_trace_index_merge_innodb.result
index 7add3824a8f..415d80b893d 100644
--- a/mysql-test/main/opt_trace_index_merge_innodb.result
+++ b/mysql-test/main/opt_trace_index_merge_innodb.result
@@ -256,15 +256,24 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
}
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": "t1.pk1 <> 0"
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null,
+ "index_condition": "t1.pk1 <> 0"
}
]
}
diff --git a/mysql-test/main/opt_trace_security.result b/mysql-test/main/opt_trace_security.result
index ab7dc1fa606..778494b549b 100644
--- a/mysql-test/main/opt_trace_security.result
+++ b/mysql-test/main/opt_trace_security.result
@@ -133,15 +133,23 @@ select * from db1.t1 {
"cost": 0.010504815
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
@@ -272,15 +280,23 @@ select * from db1.v1 {
"cost": 0.010504815
},
{
- "attaching_conditions_to_tables": {
- "attached_conditions_computation": [],
- "attached_conditions_summary": [
- {
- "table": "t1",
- "attached": null
- }
- ]
- }
+ "make_join_readinfo": [
+ {
+ "table": "t1",
+ "index_condition": null
+ }
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "attaching_conditions_to_tables": {
+ "attached_conditions_computation": [],
+ "attached_conditions_summary": [
+ {
+ "table": "t1",
+ "attached_condition": null
}
]
}
diff --git a/sql/item.cc b/sql/item.cc
index 6e93a46445c..ce55d77eb4d 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -42,6 +42,7 @@
// RESOLVED_AGAINST_ALIAS, ...
#include "sql_expression_cache.h"
#include "sql_lex.h" // empty_clex_str
+#include "my_json_writer.h" // for dbug_print_opt_trace()
const String my_null_string("NULL", 4, default_charset_info);
const String my_default_string("DEFAULT", 7, default_charset_info);
@@ -10887,6 +10888,29 @@ const char *dbug_print_item(Item *item)
return "Couldn't fit into buffer";
}
+
+/*
+ Return the optimizer trace collected so far for the current thread.
+*/
+
+const char *dbug_print_opt_trace()
+{
+ if (current_thd)
+ {
+ if (current_thd->opt_trace.is_started())
+ {
+ String *s= const_cast<String *>(current_thd->opt_trace
+ .get_current_json()->output.get_string());
+ return s->c_ptr();
+ }
+ else
+ return "Trace empty";
+ }
+ else
+ return "No Thread";
+}
+
+
const char *dbug_print_select(SELECT_LEX *sl)
{
char *buf= dbug_item_print_buf;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 054a1feaf47..f8e6a13ce97 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -42,6 +42,7 @@
#include "sql_parse.h" // check_stack_overrun
#include "sql_cte.h"
#include "sql_test.h"
+#include "opt_trace.h"
double get_post_group_estimate(JOIN* join, double join_op_rows);
@@ -3342,6 +3343,14 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
set possible optimization strategies
*/
in_subs->emb_on_expr_nest= emb_on_expr_nest;
+
+ {
+ OPT_TRACE_TRANSFORM(thd, trace_wrapper, trace_transform,
+ in_subs->get_select_lex()->select_number,
+ "EXISTS (SELECT)", "IN (SELECT)");
+ trace_transform.add( "upper_not", ( upper_not?true:false ) );
+ }
+
res= check_and_do_in_subquery_rewrites(join);
first_select->join->prepare_stage2();
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 9ceee1b5752..65b712c7a37 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -4198,6 +4198,20 @@ end:
table->all_partitions_pruned_away= true;
retval= TRUE;
}
+
+ if (unlikely(thd->trace_started()))
+ {
+ String parts;
+ String_list parts_list;
+
+ make_used_partitions_str(thd->mem_root, prune_param.part_info, &parts,
+ parts_list);
+ Json_writer_object trace_wrapper(thd);
+ Json_writer_object trace_prune(thd, "prune_partitions");
+ trace_prune.add_table_name(table);
+ trace_prune.add("used_partitions", parts.c_ptr());
+ }
+
DBUG_RETURN(retval);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c3ac3f4bcac..78e1c525c1c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -349,6 +349,8 @@ 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
@@ -3137,6 +3139,8 @@ 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)))
@@ -5112,6 +5116,8 @@ 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;
@@ -13073,10 +13079,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
/*
Step #2: Extract WHERE/ON parts
*/
- 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");
+
uint i;
for (i= join->top_join_tab_count - 1; i >= join->const_tables; i--)
{
@@ -13644,23 +13647,6 @@ 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).
- add("attached", cond);
- }
- }
}
DBUG_RETURN(0);
}
@@ -14778,7 +14764,7 @@ make_join_readinfo(JOIN *join, ulonglong options, uint no_jbuf_after)
}
check_join_cache_usage_for_tables(join, options, no_jbuf_after);
-
+
JOIN_TAB *first_tab;
for (tab= first_tab= first_linear_tab(join,
WITH_BUSH_ROOTS, WITHOUT_CONST_TABLES);
@@ -31920,6 +31906,60 @@ bool JOIN::transform_all_conds_and_on_exprs_in_join_list(
}
+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)
*/