最新原文: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 ;

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

 

 

多表

链接(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

相关文章:

  • 2021-10-11
  • 2022-02-24
  • 2021-07-19
  • 2022-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-09-19
  • 2021-04-03
猜你喜欢
  • 2021-08-21
  • 2022-12-23
  • 2021-12-06
  • 2021-08-21
  • 2021-05-10
相关资源
相似解决方案