Commit 9b6d2ad7 authored by Sergei Golubchik's avatar Sergei Golubchik

ORDER BY index traversal direction in the optimizer trace

parent d7e7f48e
...@@ -2176,6 +2176,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { ...@@ -2176,6 +2176,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
{ {
"index": "a_a", "index": "a_a",
"can_resolve_order": true, "can_resolve_order": true,
"direction": 1,
"updated_limit": 47, "updated_limit": 47,
"index_scan_time": 47, "index_scan_time": 47,
"usable": false, "usable": false,
...@@ -2184,6 +2185,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 { ...@@ -2184,6 +2185,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
{ {
"index": "a_c", "index": "a_c",
"can_resolve_order": true, "can_resolve_order": true,
"direction": 1,
"updated_limit": 47, "updated_limit": 47,
"range_scan_time": 4.331020747, "range_scan_time": 4.331020747,
"index_scan_time": 4.331020747, "index_scan_time": 4.331020747,
......
...@@ -232,9 +232,7 @@ static bool test_if_cheaper_ordering(const JOIN_TAB *tab, ...@@ -232,9 +232,7 @@ static bool test_if_cheaper_ordering(const JOIN_TAB *tab,
ha_rows *new_select_limit, ha_rows *new_select_limit,
uint *new_used_key_parts= NULL, uint *new_used_key_parts= NULL,
uint *saved_best_key_parts= NULL); uint *saved_best_key_parts= NULL);
static int test_if_order_by_key(JOIN *join, static int test_if_order_by_key(JOIN *, ORDER *, TABLE *, uint, uint *);
ORDER *order, TABLE *table, uint idx,
uint *used_key_parts);
static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order, static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,
ha_rows select_limit, bool no_changes, ha_rows select_limit, bool no_changes,
const key_map *map); const key_map *map);
...@@ -28967,6 +28965,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table, ...@@ -28967,6 +28965,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
DBUG_ASSERT (ref_key != (int) nr); DBUG_ASSERT (ref_key != (int) nr);
possible_key.add("can_resolve_order", true); possible_key.add("can_resolve_order", true);
possible_key.add("direction", direction);
bool is_covering= (table->covering_keys.is_set(nr) || bool is_covering= (table->covering_keys.is_set(nr) ||
(table->file->index_flags(nr, 0, 1) & (table->file->index_flags(nr, 0, 1) &
HA_CLUSTERED_INDEX)); HA_CLUSTERED_INDEX));
......
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