SQL - clearing execution cache
I'm trying to 开发者_JS百科profile a few queries but as you know, when you run a query a second time, it comes back in 0ms. I'm using
DBCC FREEPROCCACHE
but that doesn't seem to do the trick. what else can I run to clear any trace of execution/results cache?
CHECKPOINT;
DBCC dropcleanbuffers;
This should not be run on a production server though. CHECKPOINT
is a database scoped command that will write the dirty buffers to disc so they will be affected by the next command but DBCC dropcleanbuffers
is global and all data pages dropped from the buffer cache in this manner will need to be read in from disc when used next time.
You'll also want to use DBCC DROPCLEANBUFFERS. This will test the queries with a cold buffer cache.
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
精彩评论