Saturday 2 November 2024

SET STATISTICS PROFILE ON/OFF in SQL SERVER

The SET STATISTICS PROFILE ON command in SQL Server is used to display detailed execution plan information along with the query result. When this setting is enabled, SQL Server returns an execution plan in a tabular format with each query, showing various metrics and details about the operators used.

To enable the profile need to write the below command

SET STATISTICS PROFILE ON

See the example

Running below script

 

select top 2 sod.productID

from Sales.SalesOrderDetail sod

where exists

(select soh.salesorderid from Sales.SalesOrderHeader soh

where soh.salesorderid=sod.salesorderid

and  soh.salesorderid<43703

) 

We can see the execution plan details in the tabular format.

Graphical and tabular both are same only.

 

Tabular format is more readable format.

To disable the Profile need to set off as below.

SET STATISTICS PROFILE OFF

Running the same script and see 

Profile details are not generated.

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts