質問

In SQL Server, is there some magic SQL I can preprend my SQL query to get an estimated query cost rather than the query executed?

Possibly something like the below is my best guess myself.. seems very verbose though

SET STATISTICS PROFILE ON
GO

SELECT *  FROM [Account]

GO 
SET STATISTICS PROFILE OFF
役に立ちましたか?

解決

SET SHOWPLAN_XML ON;
GO
SELECT * FROM master..spt_values
GO
SET SHOWPLAN_XML OFF;

STATISTICS PROFILE gives you the actual plan, which means that the query will get executed. SHOWPLAN_XML or SHOWPLAN_ALL (text plan) will give you the estimated plan without executing the query. You can click on the xml result to see the graphical plan. If that does not work use SQL Sentry Plan Explorer (free) to show the plan.

他のヒント

You can use the execution plan which would give you the cost. You can do this by selecting it in the right click context menu

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top