欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

分析SQL语句性能3种方法分享

程序员文章站 2023-12-01 09:26:16
第一种方法: 复制代码 代码如下: minimsdn.com为您提供的代码: -- turn on [display io info when execute sql] s...
第一种方法:
复制代码 代码如下:

minimsdn.com为您提供的代码:
-- turn on [display io info when execute sql]
set statistics io on
-- turn off [display io info when execute sql]
set statistics io off

link: http://msdn.microsoft.com/zh-cn/library/ms184361.aspx
第二种方法:
复制代码 代码如下:

minimsdn.com为您提供的代码:
--turn on [display detail info and the request for resources]
set showplan_all on
-- turn off [display detail info and the request for resources]
set showplan_all off

link: http://msdn.microsoft.com/zh-cn/library/ms187735
第三种方法:

分析SQL语句性能3种方法分享

links: http://msdn.microsoft.com/zh-cn/library/ff650689.aspx ; http://msdn.microsoft.com/zh-cn/library/aa175244(v=sql.80).aspx
demo for three kinds of method:
for sql script:
复制代码 代码如下:

select * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc

its execution plan: (分析SQL语句性能3种方法分享)

 

分析SQL语句性能3种方法分享

its io info: (分析SQL语句性能3种方法分享)

 

分析SQL语句性能3种方法分享

-  -  you can try one table with 100/10000/1000000 rows but create/don't create clustered/nonclustered index.

its detail info etc.: (分析SQL语句性能3种方法分享)

分析SQL语句性能3种方法分享
for sql script:

复制代码 代码如下:

select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc

its execution plan: (分析SQL语句性能3种方法分享)

分析SQL语句性能3种方法分享

its io info: (分析SQL语句性能3种方法分享)

 

分析SQL语句性能3种方法分享

its detail info etc.: (分析SQL语句性能3种方法分享)

分析SQL语句性能3种方法分享

for sql script:

复制代码 代码如下:

select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
order by stagingomc.corgtpname

its execution plan: (   分析SQL语句性能3种方法分享)

 

分析SQL语句性能3种方法分享

its io info: (分析SQL语句性能3种方法分享)

分析SQL语句性能3种方法分享

its detail info etc.: (分析SQL语句性能3种方法分享)

分析SQL语句性能3种方法分享

for sql script:

复制代码 代码如下:

select top 100 stagingomc.corgtpname,count(corgid) from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
group by stagingomc.corgtpname
order by stagingomc.corgtpname

its execution plan: (分析SQL语句性能3种方法分享)

 分析SQL语句性能3种方法分享

 

its io info: (分析SQL语句性能3种方法分享)

 分析SQL语句性能3种方法分享

its detail info etc.: (分析SQL语句性能3种方法分享)

 分析SQL语句性能3种方法分享

 

-  -  by these three kinds of methods, you can try to check those words in the internet web are right or wrong about how to improve sql script performance.