[MySQL] 测试where group by order by的索引问题
2023-02-18 15:41:18 时间
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;
相关文章
- koa基础教程
- mysql中mysql数据库丢失报错Can't open the mysql.plugin table
- VUE-CLI项目同一局域网手机通过IP访问电脑本地项目
- vue-cli2和vue-cli3同时存在
- Edit Delete Mysql的主从复制
- wamp集成多个版本php (php7.0)
- sublime package control失败
- centos绑定https
- postgresql入门
- centos networkmanager 和 network配置冲突
- centos6.5 命令行配置无线上网
- CentOS 6.5 BCM43142 80211无线网卡驱动安装
- composer手动安装到windows
- [数据库] windows server 2003下mysql出现10048错误的解决办法 Can't connect to MySQL server on '127.0.0.1' (10048)
- 桥接模式-多台虚拟机配置(重要)
- VMware虚拟机中如何配置静态IP
- MySQL5.7 mysql.user创建用户
- centos有两个版本的apache
- mySQL授权(让从服务器用户可以登录到主服务器)
- mysql主从同步错误,提示The server quit without updating PID file