[MySQL] 测试where group by order by的索引问题
2023-02-18 15:46:53 时间
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;
相关文章
- 持续集成是什么?(转载)
- [编辑器]vim常用操作
- Mac下中文输入法突然没了选字框
- install dm.xmlsec.binding 失败
- [MySQL]创建数据库以及设置编码
- [MySQL]备份和导入
- [MySQL]删除一张表的所有数据
- [MySQL]增加约束键
- 第一年
- tronado: Exception: Cannot redirect after headers have been written
- [前端]npm安装慢,换用淘宝的镜像
- [MySQL]去重:DISTINCT
- Failed building wheel for lxml
- 网游中的网络编程3:在UDP上建立虚拟连接
- HTTP Header详解(转载)
- 网游中的网络编程2:发送和接收数据包
- 网游中的网络编程系列1:UDP vs. TCP
- HTTP 状态代码表示什么意思?
- 什么是web框架?
- HTTP真的很简单