七、mysql索引选择

时间:2023-03-09 22:14:13
七、mysql索引选择
1.myisam,bdb,innodb,memory 单表至少支持16个索引

2.create index id_index on emp (id) 为emp表创建一个名为id_index的id字段的索引

3.drop index id_index on emp 删除emp表的id_index 索引

4.explain xxxxxxx,可以查看相关的执行结果,用于优化表用

5.最合适的索引列是“条件列”,而不是“选择列”
比如 select name from emp where year >= 2014;
那么最好是在year字段上创建索引,而不是name字段 6.使用索引的字段,字段值最好是具有唯一性的,因为越具有唯一性,索引意义越大 7.btree索引通过索引访问,而hash索引则进行全表扫描