mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-32475 Add logging of test_if_skip_sort_order to optimizer trace
This commit is contained in:
@ -468,6 +468,9 @@ select * from v2 {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test_if_skip_sort_order": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -796,6 +799,9 @@ explain select * from v1 {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test_if_skip_sort_order": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1290,6 +1296,9 @@ EXPLAIN SELECT DISTINCT a FROM t1 {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test_if_skip_sort_order": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1485,23 +1494,27 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"reconsidering_access_paths_for_index_ordering": {
|
"test_if_skip_sort_order": [
|
||||||
"clause": "GROUP BY",
|
{
|
||||||
"fanout": 1,
|
"reconsidering_access_paths_for_index_ordering": {
|
||||||
"read_time": 3.3131,
|
"clause": "GROUP BY",
|
||||||
"table": "t1",
|
"fanout": 1,
|
||||||
"rows_estimation": 7,
|
"read_time": 3.3131,
|
||||||
"possible_keys": [
|
"table": "t1",
|
||||||
{
|
"rows_estimation": 7,
|
||||||
"index": "a",
|
"possible_keys": [
|
||||||
"can_resolve_order": true,
|
{
|
||||||
"updated_limit": 7,
|
"index": "a",
|
||||||
"index_scan_time": 7,
|
"can_resolve_order": true,
|
||||||
"records": 7,
|
"updated_limit": 7,
|
||||||
"chosen": true
|
"index_scan_time": 7,
|
||||||
|
"records": 7,
|
||||||
|
"chosen": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1687,23 +1700,27 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"reconsidering_access_paths_for_index_ordering": {
|
"test_if_skip_sort_order": [
|
||||||
"clause": "GROUP BY",
|
{
|
||||||
"fanout": 1,
|
"reconsidering_access_paths_for_index_ordering": {
|
||||||
"read_time": 2.0322,
|
"clause": "GROUP BY",
|
||||||
"table": "t1",
|
"fanout": 1,
|
||||||
"rows_estimation": 9,
|
"read_time": 2.0322,
|
||||||
"possible_keys": [
|
"table": "t1",
|
||||||
{
|
"rows_estimation": 9,
|
||||||
"index": "id",
|
"possible_keys": [
|
||||||
"can_resolve_order": true,
|
{
|
||||||
"updated_limit": 16,
|
"index": "id",
|
||||||
"index_scan_time": 16,
|
"can_resolve_order": true,
|
||||||
"records": 16,
|
"updated_limit": 16,
|
||||||
"chosen": true
|
"index_scan_time": 16,
|
||||||
|
"records": 16,
|
||||||
|
"chosen": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1878,23 +1895,27 @@ EXPLAIN SELECT * FROM t1 WHERE a = 20010104e0 GROUP BY id {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"reconsidering_access_paths_for_index_ordering": {
|
"test_if_skip_sort_order": [
|
||||||
"clause": "GROUP BY",
|
{
|
||||||
"fanout": 1,
|
"reconsidering_access_paths_for_index_ordering": {
|
||||||
"read_time": 2.0322,
|
"clause": "GROUP BY",
|
||||||
"table": "t1",
|
"fanout": 1,
|
||||||
"rows_estimation": 9,
|
"read_time": 2.0322,
|
||||||
"possible_keys": [
|
"table": "t1",
|
||||||
{
|
"rows_estimation": 9,
|
||||||
"index": "id",
|
"possible_keys": [
|
||||||
"can_resolve_order": true,
|
{
|
||||||
"updated_limit": 16,
|
"index": "id",
|
||||||
"index_scan_time": 16,
|
"can_resolve_order": true,
|
||||||
"records": 16,
|
"updated_limit": 16,
|
||||||
"chosen": true
|
"index_scan_time": 16,
|
||||||
|
"records": 16,
|
||||||
|
"chosen": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -2176,97 +2197,101 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"reconsidering_access_paths_for_index_ordering": {
|
"test_if_skip_sort_order": [
|
||||||
"clause": "ORDER BY",
|
{
|
||||||
"fanout": 1,
|
"reconsidering_access_paths_for_index_ordering": {
|
||||||
"read_time": 22.001,
|
"clause": "ORDER BY",
|
||||||
"table": "t1",
|
"fanout": 1,
|
||||||
"rows_estimation": 21,
|
"read_time": 22.001,
|
||||||
"possible_keys": [
|
"table": "t1",
|
||||||
{
|
"rows_estimation": 21,
|
||||||
"index": "a_a",
|
"possible_keys": [
|
||||||
"can_resolve_order": true,
|
{
|
||||||
"updated_limit": 47,
|
"index": "a_a",
|
||||||
"index_scan_time": 47,
|
"can_resolve_order": true,
|
||||||
"usable": false,
|
"updated_limit": 47,
|
||||||
"cause": "cost"
|
"index_scan_time": 47,
|
||||||
},
|
"usable": false,
|
||||||
{
|
"cause": "cost"
|
||||||
"index": "a_c",
|
},
|
||||||
"can_resolve_order": true,
|
{
|
||||||
"updated_limit": 47,
|
"index": "a_c",
|
||||||
"range_scan_time": 4.324,
|
"can_resolve_order": true,
|
||||||
"index_scan_time": 4.324,
|
"updated_limit": 47,
|
||||||
"records": 180,
|
"range_scan_time": 4.324,
|
||||||
"chosen": true
|
"index_scan_time": 4.324,
|
||||||
},
|
"records": 180,
|
||||||
{
|
"chosen": true
|
||||||
"index": "a_b",
|
},
|
||||||
"can_resolve_order": false,
|
{
|
||||||
"cause": "not usable index for the query"
|
"index": "a_b",
|
||||||
|
"can_resolve_order": false,
|
||||||
|
"cause": "not usable index for the query"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"table": "t1",
|
|
||||||
"range_analysis": {
|
|
||||||
"table_scan": {
|
|
||||||
"rows": 1000,
|
|
||||||
"cost": 2e308
|
|
||||||
},
|
},
|
||||||
"potential_range_indexes": [
|
{
|
||||||
{
|
"table": "t1",
|
||||||
"index": "a_a",
|
"range_analysis": {
|
||||||
"usable": false,
|
"table_scan": {
|
||||||
"cause": "not applicable"
|
"rows": 1000,
|
||||||
},
|
"cost": 2e308
|
||||||
{
|
},
|
||||||
"index": "a_c",
|
"potential_range_indexes": [
|
||||||
"usable": true,
|
{
|
||||||
"key_parts": ["a", "c"]
|
"index": "a_a",
|
||||||
},
|
"usable": false,
|
||||||
{
|
"cause": "not applicable"
|
||||||
"index": "a_b",
|
},
|
||||||
"usable": false,
|
{
|
||||||
"cause": "not applicable"
|
"index": "a_c",
|
||||||
}
|
"usable": true,
|
||||||
],
|
"key_parts": ["a", "c"]
|
||||||
"setup_range_conditions": [],
|
},
|
||||||
"group_index_range": {
|
{
|
||||||
"chosen": false,
|
"index": "a_b",
|
||||||
"cause": "no group by or distinct"
|
"usable": false,
|
||||||
},
|
"cause": "not applicable"
|
||||||
"analyzing_range_alternatives": {
|
}
|
||||||
"range_scan_alternatives": [
|
],
|
||||||
{
|
"setup_range_conditions": [],
|
||||||
"index": "a_c",
|
"group_index_range": {
|
||||||
"ranges": ["(1) <= (a) <= (1)"],
|
"chosen": false,
|
||||||
"rowid_ordered": false,
|
"cause": "no group by or distinct"
|
||||||
"using_mrr": false,
|
},
|
||||||
"index_only": false,
|
"analyzing_range_alternatives": {
|
||||||
"rows": 180,
|
"range_scan_alternatives": [
|
||||||
"cost": 229.72,
|
{
|
||||||
|
"index": "a_c",
|
||||||
|
"ranges": ["(1) <= (a) <= (1)"],
|
||||||
|
"rowid_ordered": false,
|
||||||
|
"using_mrr": false,
|
||||||
|
"index_only": false,
|
||||||
|
"rows": 180,
|
||||||
|
"cost": 229.72,
|
||||||
|
"chosen": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"analyzing_roworder_intersect": {
|
||||||
|
"cause": "too few roworder scans"
|
||||||
|
},
|
||||||
|
"analyzing_index_merge_union": []
|
||||||
|
},
|
||||||
|
"chosen_range_access_summary": {
|
||||||
|
"range_access_plan": {
|
||||||
|
"type": "range_scan",
|
||||||
|
"index": "a_c",
|
||||||
|
"rows": 180,
|
||||||
|
"ranges": ["(1) <= (a) <= (1)"]
|
||||||
|
},
|
||||||
|
"rows_for_plan": 180,
|
||||||
|
"cost_for_plan": 229.72,
|
||||||
"chosen": true
|
"chosen": true
|
||||||
}
|
}
|
||||||
],
|
}
|
||||||
"analyzing_roworder_intersect": {
|
|
||||||
"cause": "too few roworder scans"
|
|
||||||
},
|
|
||||||
"analyzing_index_merge_union": []
|
|
||||||
},
|
|
||||||
"chosen_range_access_summary": {
|
|
||||||
"range_access_plan": {
|
|
||||||
"type": "range_scan",
|
|
||||||
"index": "a_c",
|
|
||||||
"rows": 180,
|
|
||||||
"ranges": ["(1) <= (a) <= (1)"]
|
|
||||||
},
|
|
||||||
"rows_for_plan": 180,
|
|
||||||
"cost_for_plan": 229.72,
|
|
||||||
"chosen": true
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -23608,8 +23608,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||||||
bool orig_cond_saved= false;
|
bool orig_cond_saved= false;
|
||||||
int best_key= -1;
|
int best_key= -1;
|
||||||
bool changed_key= false;
|
bool changed_key= false;
|
||||||
|
THD *thd= tab->join->thd;
|
||||||
DBUG_ENTER("test_if_skip_sort_order");
|
DBUG_ENTER("test_if_skip_sort_order");
|
||||||
|
|
||||||
|
Json_writer_object trace_wrapper(thd);
|
||||||
|
Json_writer_array trace_arr(thd, "test_if_skip_sort_order");
|
||||||
|
|
||||||
/* Check that we are always called with first non-const table */
|
/* Check that we are always called with first non-const table */
|
||||||
DBUG_ASSERT(tab == tab->join->join_tab + tab->join->const_tables);
|
DBUG_ASSERT(tab == tab->join->join_tab + tab->join->const_tables);
|
||||||
|
|
||||||
@ -23618,6 +23622,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
|
|||||||
tab->type == JT_CONST ||
|
tab->type == JT_CONST ||
|
||||||
tab->type == JT_SYSTEM)
|
tab->type == JT_SYSTEM)
|
||||||
{
|
{
|
||||||
|
Json_writer_object trace_skip(thd);
|
||||||
|
trace_skip.add("skipped", "single row access method");
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user