How to shrink the tempdb database in SQL Server

本文解释了为何在SQL Server中缩小数据库文件大小往往不起作用,特别是针对TempDB的情况,并提供了一些非常规方法来解决此问题。还讨论了这些方法可能带来的性能影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方文档

http://support.microsoft.com/kb/307487


很多时候会发现,shrink DB后,数据文件的大小没有变化。甚至在shrink前显示文件的availabl free space非常大,shrink也不起什么作用。原因是:

It's more a function of how SQL Server relies more and more on TempDB in each release. When something's active in TempDB, you can't move its data around, and each new version of SQL Server works more in TempDB. For example, when you enable Read Committed Snapshot Isolation, the version store it uses lives in TempDB. When you use AlwaysOn Availability Groups, it tracks user database statistics in TempDB too. This is just another reason why you set aside a logical volume for TempDB, size the data files to fill it up, and then walk away - your work here is done, and don't try to shrink those files.

这里有其他非常规的方法来shrink tempDB,大致就是删除tempDB存储的一些catch文件。但是在production应该严禁使用,因为这些命令会严重影响数据库的性能。例如,

DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE

但是DBA可以根据实际情况在其他非production使用。具体是方法

http://sqlsunday.com/2013/08/11/shrinking-tempdb-without-restarting-sql-server/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值