Chris Pfohl
Chris Pfohl

Reputation: 19054

How to bypass SQL Server caching

When I am trying to examine the performance of a given query in my application I'm generally uninterested in the effect my code is having. I want to be able to watch the time taken in Sql Management Studio.

Unfortunately, I'm finding that some sort of caching must be going on, because one query that returns 10,000 results from a table with 26 or so columns, many of them large varchars, takes 12 seconds the first time I run it in a while and takes 6 seconds the following times unless I don't re-run it for a few minutes.

Is there any way to instruct it to bypass the cache and pretend like it had never run it before? I'm using SQL Server 10.0.

Upvotes: 2

Views: 454

Answers (1)

dfb
dfb

Reputation: 13289

You can clean out the cache and sproc cache with

DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE

respectively

Upvotes: 3

Related Questions