分析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
第三种方法:
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
select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
order by stagingomc.corgtpname
select top 100 stagingomc.corgtpname,count(corgid) from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
group by stagingomc.corgtpname
order by stagingomc.corgtpname
复制代码 代码如下:
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
v its execution plan: ()
v its io info: ()
- - you can try one table with 100/10000/1000000 rows but create/don't create clustered/nonclustered index.
v its detail info etc.: ()
for sql script:
复制代码 代码如下:
select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
v its execution plan: ()
v its io info: ()
v its detail info etc.: ()
for sql script:
复制代码 代码如下:
select top 100 * from dbebmsstaging.dbo.mssalestxlatorganizationmaster_corg stagingomc
order by stagingomc.corgtpname
v its execution plan: ( )
v its io info: ()
v 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
v its execution plan: ()
v its io info: ()
v 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.
上一篇: sql 语句中的 NULL值