troubleshooting Question

detecting query recompilation / sql server 2008

Avatar of pae2
pae2Flag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
3 Comments1 Solution338 ViewsLast Modified:
I'm trying to detect if I have some queries that are recompiling for requests from different users opposed to using cache. Here's how I plan on doing that:

USE DB

GO
DBCC dropcleanbuffers
DBCC freeproccache

GO

SET STATISTICS TIME ON

GO

SELECT STATEMENT

GO

SELECT STATEMENT

I realize that this will provide parse/compile and execution time.

The problem is that when User-A executes a particular query, it's slow at first and then fast after subsequent requests. When User-B executes that very same query, it's also slow at first and then faster after subsequent requests.

Will the foregoing be able to tell me whether or not the query is recompiled for User-B after it has compiled for User-A?

Ideally, I'm hoping that it'll compile for User-A and then just reference the existing plan/cache for User-B.

Will existing indexes impact this analysis? Should I drop them?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros