在需要测试sql语句或者存储过程性能的时候可以用得上
CHECKPOINT
--
用于检查当前工作的数据库中被更改过的数据页或日志页,并将这些数据从数据缓冲器中强制写入硬盘
GO
DBCC FreeProcCache -- 从缓冲池中删除所有缓冲区
DBCC DropCleanBuffers -- 从过程高速缓存中删除所有元素
GO
DBCC FreeSystemCache( ' ALL ' ) ; -- 清除SQL实例的计划缓存
GO
SET Statistics IO ON
SET Statistics TIME ON
GO
-- -------------------------
DECLARE @b datetime
DECLARE @e datetime
set @b = getdate ();
select COUNT ( * ) from test1;
set @e = getdate ();
select DATEDIFF (ms, @b , @e )
-- --------------------------
SET Statistics IO OFF
SET Statistics TIME OFF
GO
DBCC DropCleanBuffers
DBCC FreeProcCache
GO
DBCC FreeProcCache -- 从缓冲池中删除所有缓冲区
DBCC DropCleanBuffers -- 从过程高速缓存中删除所有元素
GO
DBCC FreeSystemCache( ' ALL ' ) ; -- 清除SQL实例的计划缓存
GO
SET Statistics IO ON
SET Statistics TIME ON
GO
-- -------------------------
DECLARE @b datetime
DECLARE @e datetime
set @b = getdate ();
select COUNT ( * ) from test1;
set @e = getdate ();
select DATEDIFF (ms, @b , @e )
-- --------------------------
SET Statistics IO OFF
SET Statistics TIME OFF
GO
DBCC DropCleanBuffers
DBCC FreeProcCache
执行结果如下:---------------------------------------------------------
每天进步一点点...
