Blogger Information
Blog 6
fans 0
comment 1
visits 4337
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Mysql索引优化一
jaronHu的博客
Original
744 people have browsed it

如何选择合适的列建立索引

1.在where从句,group by 从句,order by 从句中,on 从句中出现的列

2.索引字段越小越好

3.离散度大的列放到联合索引的前面

eg: select * from table where staff_id = 2 and customer_id = 588;

是index(staff_id,customer_id) 好? 还是 index(customer_id,staff_id)好?

**判断谁的离散度大,如何判断?**

select count(distinct customer_id),count(distinct staff_id) from table;

**谁的值大就在创建索引的时候,把那个字段放在前面**



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
jaronHu 2017-07-27 15:28:16
0.0
1 floor
Author's latest blog post