I have a very long SQL script including 1500 rows of code and someone think it's slow and hope I can find slow queries inside it and tune them.
I use SET STATISTICS TIME ON
to print out real elapsed time for each steps in the script and found some of them are quit slow, such as :
/***********************************************/
CPU time = 0 ms, elapsed time = 1 ms.
(0 row(s) affected)
(1 row(s) affected)
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 1 ms.
(4 row(s) affected)
(1 row(s) affected)
SQL Server Execution Times:
CPU time = 15 ms, elapsed time = 10548 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 2 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 1 ms.
/***********************************************/
But the problem is I cannot pinpoint which query spent such long time, because the script is too long. How can I know which query in this long script spent 10548 ms?
Thanks!