mirror of
https://github.com/MariaDB/server.git
synced 2025-07-20 16:56:36 +00:00
MDEV-37252 Do not check is_key_used in get_index_for_order
This allows UPDATE to use ORDER BY indexes in the update columns.
This commit is contained in:
@ -72,7 +72,7 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
# This should use an index, possible_keys=NULL because there is no WHERE
|
||||
explain update t1 set a=a+1 order by a limit 2;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 512 Using filesort
|
||||
1 SIMPLE t1 index NULL a 5 NULL 2 Using buffer
|
||||
# This should use range, possible_keys={a,b}
|
||||
explain update t1 set filler='fooo' where a<20 and b < 10;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
|
@ -288,7 +288,7 @@ update t1 set a=9999 order by a limit 1;
|
||||
update t1 set b=9999 order by a limit 1;
|
||||
show status like 'handler_read%';
|
||||
Variable_name Value
|
||||
Handler_read_first 1
|
||||
Handler_read_first 2
|
||||
Handler_read_key 0
|
||||
Handler_read_last 0
|
||||
Handler_read_next 0
|
||||
@ -296,7 +296,7 @@ Handler_read_prev 0
|
||||
Handler_read_retry 0
|
||||
Handler_read_rnd 2
|
||||
Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 9
|
||||
Handler_read_rnd_next 0
|
||||
flush status;
|
||||
delete from t1 order by a limit 1;
|
||||
show status like 'handler_read%';
|
||||
|
@ -33411,8 +33411,7 @@ uint get_index_for_order(ORDER *order, TABLE *table, SQL_SELECT *select,
|
||||
double new_cost;
|
||||
if (test_if_cheaper_ordering(FALSE, NULL, order, table,
|
||||
table->keys_in_use_for_order_by, -1, limit,
|
||||
&key, &direction, &limit, &new_cost) &&
|
||||
!is_key_used(table, key, table->write_set))
|
||||
&key, &direction, &limit, &new_cost))
|
||||
{
|
||||
*need_sort= FALSE;
|
||||
*scanned_limit= limit;
|
||||
|
Reference in New Issue
Block a user