数据库 
首页 > 数据库 > 浏览文章

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

(编辑:jimmy 日期: 2024/11/14 浏览: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
第三种方法:

分析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.

上一篇:INSERT INTO SELECT语句与SELECT INTO FROM语句的一些区别
下一篇:sqlserver中重复数据值只取一条的sql语句
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。