How to shrink the tempdb database in SQL Server
2014-01-20 14:12
831 查看
官方文档
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/
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/
相关文章推荐
- How to select the data type in SQLserver database such as varchar, nvarchar
- How to recreate the msdb database in SQL Server 2005
- How to Kill All Processes That Have Open Connection in a SQL Server Database[关闭数据库链接 最佳方法] -摘自网络
- How to move the databases that are used by SharePoint Portal Server 2003 to a computer that is running SQL Server
- How To Trace The Remote File Server (RFS) Process In Physical Standby Database (Doc ID 1481125.1)
- How to get the SQL Server name (Database server)?
- HOW TO: Change the Owner of a User-Defined Data Type That Is in Use in SQL Server 2000
- How to read and save Images in a Sql Server Database using ADO.NET and C#
- Could not store transport type data for Receive Location 'Recv.Loc' to config store. Primary SSO Server 'Sql-server' failed. The external credentials in the SSO database are more recent.
- Windows Phone 7.5 - Local SQL Database:How to read the DB schema in windows phone 7
- server 2 task(s) are sleeping waiting for space to become available in the log segment for database tempdb.
- How to troubleshoot the performance of Ad-Hoc queries in SQL Server [ZT-from MS]
- How to grant access to SQL logins on a standby database when the guest user is disabled in SQL Serve
- How to backup and restore database in SQL Server
- How to search the available space in SQL server.
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versio
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
- How to enable remote connections in SQL Server 2008?
- MySQL "show users" - how to show/list the users in a MySQL database
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version