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

时间:2021-05-02

第一种方法:

复制代码 代码如下:


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:
第二种方法:

复制代码 代码如下:


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:
第三种方法:

Links: ; (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.

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章