何时创建索引
1检索的数据才表的数据的15%一下
2参与表连接的列
3主键或唯一约束的列
一般很多空值的列不适合创建索引
在多个列上创建索引时,查询时use the leading portion of the index.
比如
CREATE INDEX ind_vendor_id ON vendor_parts (part_no, vendor_id);
SELECT * FROM vendor_parts WHERE part_no = 457 AND vendor_id = 1012;
SELECT * FROM vendor_parts WHERE vendor_id = 1012 and part_no = 457;
SELECT * FROM vendor_parts WHERE part_no = 457 ;
都是可以的
SELECT * FROM vendor_parts WHERE vendor_id = 1012;
将无法应用索引