1. select * from test where a=xx group by b order by c 如何加索引
CREATE table `index_test` (
`ID` int(10) unsigned NOT NulL auto_INCREMENT,
`name` varchar(100) NOT NulL DEFAulT '',
`gID` int(11) NOT NulL DEFAulT '0',
`age` int(11) NOT NulL DEFAulT '0',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAulT CHARSET=utf8
MysqL> select * from index_test;
+----+------------+-----+
| ID | name | gID |
+----+------------+-----+
| 1 | taoshihan | 2 |
| 2 | taoshihan1 | 2 |
+----+------------+-----+
2. 加个联合索引试试
alter table index_test add index name_gID_age_index(name,gID,age);
explain select * from index_test where name='taoshihan' group by gID order by age;
总结
以上是内存溢出为你收集整理的[MySQL] 测试where group by order by的索引问题全部内容,希望文章能够帮你解决[MySQL] 测试where group by order by的索引问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)