【发布时间】:2014-04-01 01:14:06
【问题描述】:
我有一个 mysql innodb 表,我在其中使用不同的列执行大量选择。我认为在每个字段上添加索引可以提高性能,但是在阅读了一些索引之后,我不确定在您选择的列上添加索引是否总是有帮助。
在我的情况下,我有比插入/更新更多的选择。
我的桌子“学生”看起来像:
id | student_name | nickname | team | time_joined_school | honor_roll
我有以下疑问:
# The team column is varchar(32), and only has about 20 different values.
# The honor_roll field is a smallint and is only either 0 or 1.
1. select from students where team = '?' and honor_roll = ?;
# The student_name field is varchar(32).
2. select from students where student_name = '?';
# The nickname field is varchar(64).
3. select from students where nickname like '%?%';
所有结果都按time_joined_school排序,这是一个bigint(20)。
所以我只想在每一列上添加一个索引,在这种情况下这有意义吗?
谢谢
【问题讨论】:
标签: mysql