Link to home
Create AccountLog in
Avatar of pae2
pae2Flag for United States of America

asked on

detecting query recompilation / sql server 2008

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?
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I hope you don't do the freecache/cleanbuffers on your production server. That is best only used on your local instance
I'm seeing your series of questions about monitoring performance. You may want to look at getting Confio's Ignite monitoring software. The free version gives you a fair amount of data like this.

http://www.confio.com/performance/sql-server/ignite/