SQL for Query Cost Estimation on SQL Server
In SQL Server, is there some magic SQL, I can preload my SQL query to get the estimated cost of the query, not the executed query?
Maybe something like below is my best guess. Seems very verbose though
SET STATISTICS PROFILE ON
GO
SELECT * FROM [Account]
GO
SET STATISTICS PROFILE OFF
+3
source to share
2 answers
SET SHOWPLAN_XML ON;
GO
SELECT * FROM master..spt_values
GO
SET SHOWPLAN_XML OFF;
STATISTICS PROFILE
gives you the actual plan, which means the request will be executed. SHOWPLAN_XML
or SHOWPLAN_ALL
(textual plan) will give you a calculation plan without running the query. You can click on the xml result to see the graphical plan. If that doesn't work, use SQL Sentry Plan Explorer (free) to show the plan.
+3
source to share