mysql 索引优先级规则是如何的?例如:
索引1:名字为a, 索引字段(qq,ww,ee,rr)
索引2:名字为b, 索引字段(qq,ww,ee,tt)在执行一条查询语句,用到qq,ww,ee这3个索引 mysql如何去选择a或者b呢
索引1:名字为a, 索引字段(qq,ww,ee,rr)
索引2:名字为b, 索引字段(qq,ww,ee,tt)在执行一条查询语句,用到qq,ww,ee这3个索引 mysql如何去选择a或者b呢
如果语句仅仅是
select * from xxx where qq = ? and ww =? and ee =?则MYSQL会随机选择一个索引,一般是已加载在内存中的或者第一个。
场景:
------------------------------
aa表中字段(aa_id,aa_cash,in_time,temp_id,gg_id,out_cash)aa_id是主键
bb_class表中字段(gg_id,gg_name) gg_id是主键
aa表的索引:
(1)temp_id,in_time, gg_id,aa_cash
(2)temp_id,in_time, gg_id,out_cash
查询语句:
select count(aa_id) from aa a,bb_class b where b.aa_id=4 and a.temp_id=30 and a.in_time > now() and a.gg_id =b.gg_id;
这样来说,mysql会只能去选择查询会比较快的索引?、
求解