Reputation:
I am struggling with a strange problem using Sql Profiler. While running some performance testing scripts, I run profiler to find bottlenecks. One particular statement seems to be taking a lot of time - with CPU 1407, Reads 75668 and Duration of 175.
However when I run the same statement in Management Studio, SQL Profiler returns CPU 16, Reads 4 & Duration 55.
Can anyone point me towards what I am doing wrong, as I am completely baffled by this.
Thanks, Susan.
Upvotes: 0
Views: 334
Reputation: 34421
If you run the query in enterprise manager directly after the profiling, all pages it needs will be cached in memory. This can lead to drastic improvements.
If you right-click the server in Enterprise Manager and select Properties, you can change the amount of memory available to the server. If you change this number even one step, SQL server will flush its cache.
Upvotes: 0
Reputation: 432561
You may have a scalar user defined function that has table access.
The resources used are only picked up by profiler: SSMS won't show the internal IO or CPU of the scalar udf.
Example:
CREATE FUNCTION dbo.MyUdf (
@param int
)
AS
RETURNS int
BEGIN
RETURN (SELECT MAX(foo) FROM dbo.MyOtherTable WHERE Key = @param)
END
GO
SELECT
col1, col2, dbo.MyUdf(col3)
FROM
dbo.MyFirstTable
However, this may not explain duration...
Upvotes: 3