且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何清除SQL Server查询缓存?

更新时间:2023-02-06 10:33:49

这里有一些很好的解释。

Here is some good explaination. check out it.

http: //www.mssqltips.com/tip.asp?tip=1360

CHECKPOINT; 
GO 
DBCC DROPCLEANBUFFERS; 
GO

来自链接的文章:


如果所有性能测试都在SQL Server中进行,***的方法可能是发出CHECKPOINT,然后发出DBCC DROPCLEANBUFFERS命令。尽管CHECKPOINT进程是SQL Server中的一个自动内部系统进程,并且会定期发生,但是发出此命令以将当前数据库的所有脏页写入磁盘并清理缓冲区很重要。然后可以执行DBCC DROPCLEANBUFFERS命令从缓冲池中删除所有缓冲区。

If all of the performance testing is conducted in SQL Server the best approach may be to issue a CHECKPOINT and then issue the DBCC DROPCLEANBUFFERS command. Although the CHECKPOINT process is an automatic internal system process in SQL Server and occurs on a regular basis, it is important to issue this command to write all of the dirty pages for the current database to disk and clean the buffers. Then the DBCC DROPCLEANBUFFERS command can be executed to remove all buffers from the buffer pool.