首页 / 更多教程 / SQL优化案例分享--联合索引
SQL优化案例分享--联合索引
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了SQL优化案例分享--联合索引,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2180字,纯文字阅读大概需要4分钟。
内容图文
![SQL优化案例分享--联合索引](/upload/InfoBanner/zyjiaocheng/482/1836ab3a8dae4f4a95740d988485c031.jpg)
mysql> desc select sql_no_cache count(*) as total from Art_Works b,Art_Person a force index (PersonCode) where b.PersonCode=a.PersonCode;
+----+-------------+-------+-------+---------------+------------+---------+---------------------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+------------+---------+---------------------+--------+-------------+
| 1 | SIMPLE | b | index | PersonCode | PersonCode | 25 | NULL | 173223 | Using index |
| 1 | SIMPLE | a | ref | PersonCode | PersonCode | 24 | newart.b.PersonCode | 13 | Using index |
+----+-------------+-------+-------+---------------+------------+---------+---------------------+--------+-------------+
2 rows in set (0.00 sec)
mysql> alter table Art_Works add index idx_PU(PersonCode,PID);
Query OK, 173223 rows affected (5.73 sec)
Records: 173223 Duplicates: 0 Warnings: 0
mysql> desc select sql_no_cache count(*) as total from Art_Works b,Art_Person a force index (PersonCode) where b.PersonCode=a.PersonCode;
+----+-------------+-------+-------+-------------------+------------+---------+---------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+-------------------+------------+---------+---------------------+------+--------------------------+
| 1 | SIMPLE | a | index | PersonCode | PersonCode | 24 | NULL | 8910 | Using index |
| 1 | SIMPLE | b | ref | PersonCode,idx_PU | idx_PU | 25 | newart.a.PersonCode | 1 | Using where; Using index |
+----+-------------+-------+-------+-------------------+------------+---------+---------------------+------+--------------------------+
2 rows in set (0.00 sec)
SQL优化案例分享--联合索引
标签:sql优化
本文系统来源:http://songlisha.blog.51cto.com/6269280/1925090
内容总结
以上是互联网集市为您收集整理的SQL优化案例分享--联合索引全部内容,希望文章能够帮你解决SQL优化案例分享--联合索引所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。