sql优化实操:根据explain的结果,对sql进行优化


最新原文:https://www.cnblogs.com/uncleyong/p/14805395.html

说明及要求

说明:

  sql优化不只是考虑索引等,有时候还需要对业务逻辑进行优化。本题暂不考虑业务逻辑。

要求:

  1、描述现在sql存在的问题

  2、描述优化方案,每一个优化改动是为了解决什么问题

 

单表

表结构

create table stu
(
	sid int(4) primary key,
	sname varchar(20) not null,
	phone int(11) not null,
	addr varchar(20) not null,
	class_id int(4) not null,
	grade_id int(4) not null
);

 

explain结果 

explain select sid from stu where grade_id in(2,3) and class_id=1 order by grade_id desc ;

 

 

多表

链接(https://www.cnblogs.com/uncleyong/p/14758383.html)中第28题,

自己先写sql,然后做优化 

 

 

 

最新原文:https://www.cnblogs.com/uncleyong/p/14805395.html

 

bak:https://www.cnblogs.com/uncleyong/p/14814185.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM