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

第一种方法:


复制代码 代码如下:

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


第三种方法:

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: ()

 

its io info: ()

 

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

its detail info etc.: ()


for sql script:

复制代码 代码如下:

select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc

its execution plan: ()

its io info: ()

 

its detail info etc.: ()

for sql script:

复制代码 代码如下:

select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc

order by stagingomc.corgtpname

its execution plan: (   )

 

its io info: ()

its detail info etc.: ()

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: ()

 

 

its io info: ()

 

its detail info etc.: ()

 

 

–  –  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.

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐