简介
测试中发现mysqld的trace结果与查询计划不相同的情况,记录下,并且已经提交给了官方
查询计划:
mysql> explain select id,uuid,link_uuid,laundry_uuid,from_user,to_user,amount,principal,interest,sequence,pay_status,product_code, start_time,end_time,bid_uuid,tbid_uuid,interest_day,repay_amount,link_count,create_time,update_time, parent_repay_amount,parent_repayed_amount,total_amount,overdue_interest,overdue_day,rate,parent_repay_user, delay_day,delay_interest,overdue_rate,parent_uuid,product_create_time,law_status,law_time, call_version, original_principal, original_interest, gurantee_uuid, type, source_bid_uuid from repay_flow where from_user='499200489766955660' and overdue_day=3 and pay_status=4 and id>0 order by uuid desc limit 1\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: repay_flow
partitions: NULL
type: index
possible_keys: PRIMARY,index_from_user_to_user
key: index_uuid
key_len: 62
ref: NULL
rows: 2650
filtered: 0.00
Extra: Using where
1 row in set, 1 warning (0.00 sec)
trace结果如下,只列出关键部分:
{
"added_back_ref_condition": "((`repay_flow`.`from_user` <=> '499200489766955660') and ((`repay_flow`.`pay_status` = 4) and (`repay_flow`.`overdue_day` = 3) and (`repay_flow`.`id` > 0)))"
},
{
"reconsidering_access_paths_for_index_ordering": {
"clause": "ORDER BY",
"index_order_summary": {
"table": "`repay_flow`",
"index_provides_order": true,
"order_direction": "desc",
"index": "index_from_user_to_user",
"plan_changed": false ##此处为trace结果的最终选择,就是在优化器考虑了order by 选项后,依然选择需要进行filesort的 index_from_user_to_user索引。
}