1.超过300条记录,就应该建立索引
2.应该建立索引的字段:
1.主键和外键上必须有索引
2.经常与其它表连接的连接字段
3.经常进行范围查询的列
4.经常排序查询的列
5.where子句中的字段
6.group by、order by、distnict字段后面的字段
3.不应该建立索引的字段:
1.查询很少的列
2.区分度不高(大量重复值)的列
3.text, image和bit数据类型的列。这些列的数据量要么相当大,要么取值很少
4.经常被修改的列