开发者

can i cleanup buffer for some specified database instead of the entire sql server

开发者 https://www.devze.com 2023-02-22 16:17 出处:网络
from what i know, if i execute \'DBCC FREEPROCCACHE\' and \'DBCC DROPCLEANBUFFERS\', the buffer of entire server will be cleanup.

from what i know, if i execute 'DBCC FREEPROCCACHE' and 'DBCC DROPCLEANBUFFERS', the buffer of entire server will be cleanup. i wonder if there's anyway to cleanup buffer of specified database only. therefore, query for other databases will not be开发者_如何学Python affected.


You can clear all execution plans from a single database using DBCC FLUSHPROCINDB(<db_id>). I'm not aware of any similar command to clear specific pages from the buffer cache.

However, you can set the database offline momentarily and then back online to clear both plan and buffer caches for a database if the situation allows for this.


Not a possibility with FREEPROCCACHE or DBCC FREEPROCCACHE

As per msdn https://msdn.microsoft.com/en-us/library/cc293622.aspx

DBCC FREEPROCCACHE This command removes all cached plans from memory DBCC FLUSHPROCINDB (<dbid>) This command allows you to specify a particular database id, and then clears all plans from that particular database.

db id can be fetched this way

DECLARE @intDBID INT;
SET @intDBID = (SELECT [dbid] 
                FROM master.dbo.sysdatabases 
                WHERE name = 'AdventureWorks');

-- Flush the procedure cache for one database only
DBCC FLUSHPROCINDB (@intDBID);
0

精彩评论

暂无评论...
验证码 换一张
取 消