Microsoft SQL Server 2005 Administration
Best Practices

How to reset memory to measure timing accurately?

 

Execute the following script in Query Editor to flush memory clean in preparation for a timing measurement:

USE AdventureWorks
GO

DBCC DROPCLEANBUFFERS -- Clears the data cache
DBCC FREEPROCCACHE -- Clears the procedure cache

declare @StartTime datetime
set @StartTime = getdate()

/*

PUT SCRIPT HERE ******************************

*/

 

print 'Duration in msec = '
+ convert(varchar, datediff(ms, @StartTime, getdate()))

GO

 

 

The Best SQL Server 2005 Training in the World
 
 
SQLUSA.com Home Page