分析SQL語(yǔ)句性能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
第三種方法:
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.
相關(guān)文章
在sql Server自定義一個(gè)用戶定義星期函數(shù)
程序開(kāi)發(fā)過(guò)程中需要做周別統(tǒng)計(jì)與顯示報(bào)表。在做之前,得先找出所在年份周別的開(kāi)始日期與結(jié)束日期。每年每周的開(kāi)始與結(jié)束日期都不盡相同。為了該功能,在sql Server自定義一個(gè)用戶定義星期函數(shù)2012-01-01實(shí)例理解SQL中truncate和delete的區(qū)別
這篇文章主要介紹了實(shí)例理解SQL中truncate和delete的區(qū)別,truncate和delete兩者易混,本文就為大家進(jìn)行區(qū)分兩者的異同,感興趣的小伙伴們可以參考一下2016-02-02實(shí)現(xiàn)SQL Server 原生數(shù)據(jù)從XML生成JSON數(shù)據(jù)的實(shí)例代碼
這篇文章主要介紹了實(shí)現(xiàn)SQL Server 原生數(shù)據(jù)從XML生成JSON數(shù)據(jù)的實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2017-03-03SQL Server SQL Agent服務(wù)使用教程小結(jié)
SQL Server SQL Agent服務(wù)使用教程小結(jié)...2007-03-03sqlserver中的自定義函數(shù)的方法小結(jié)
“自定義函數(shù)”是我們平常的說(shuō)法,而“用戶定義的函數(shù)”是 SQL Server 中書(shū)面的說(shuō)法。2010-06-06SQL?Server中的XML數(shù)據(jù)類(lèi)型詳解
本文詳細(xì)講解了SQL?Server中的XML數(shù)據(jù)類(lèi)型,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-05-05CREATE FUNCTION sqlserver用戶定義函數(shù)
創(chuàng)建用戶定義函數(shù),它是返回值的已保存的 Transact-SQL 例程。用戶定義函數(shù)不能用于執(zhí)行一組修改全局?jǐn)?shù)據(jù)庫(kù)狀態(tài)的操作。與系統(tǒng)函數(shù)一樣,用戶定義函數(shù)可以從查詢中喚醒調(diào)用。也可以像存儲(chǔ)過(guò)程一樣,通過(guò) EXECUTE 語(yǔ)句執(zhí)行2012-07-07