r/SQLServer • u/Odd_Part8454 • May 21 '26
Question Simple SQL tool for a developer to see runtimes/reads and identify the longest running statement
I inherited a sql server script that's close to a thousand lines. I don't want to run each statement one by one and look at execution times. Is there a simple tool out there that runs the long anonymous script and gives me a simple tabular output (such as reads/writes/time taken to parse/execute)..
5
Upvotes
2
u/Better-Credit6701 May 21 '26
Pretty simple to do with a script. I can even see what step a SSIS package is on with a simple script
2
u/PrisonerOne May 21 '26
I'd just run it once and look the execution plan. & Lately, I've been using Erik Darling's Performance Studio. It is a great tool to dig into execution plans.
2
u/thatto May 22 '26
Set statistics io,time on;
Run the script
STATISTICS IO ON: Displays the amount of physical and logical disk activity (read/write metrics) required to run your query. STATISTICS TIME ON: Shows the total parsing, compilation, and execution times in milliseconds, breaking down the specific CPU load and elapsed time. Output is in the messages tab.
5
u/Complete-Fondant-202 May 21 '26
If querystore is enabled, and you can guarantee no activity while you run the script you could use Erik Darlings sp_quickiestore after the fact possibly, witha start_date parameter suitable set to a second before you ran your script?
1
u/Comfortable-Zone-218 May 22 '26
Get Plan Explorer. So good!
2
u/ihaxr 2 May 21 '26
Include live query statistics...?
https://www.sqlservercentral.com/blogs/live-query-statistics
1
u/Admirable_Writer_373 May 21 '26
Query story or an old school trace
1
u/Lost_Term_8080 May 22 '26
use sp_BlitzCache with `@StoredProcName after running it once
1
u/CPDRAGMEISH May 25 '26 edited May 25 '26
IT'SG Ok
sys.dm_exec_query_stats
SSMS Activity Moitor Recent & Active Expensive Querys
QueryStore