Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shrink tempdb database

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Customer requirements:

This is a production environment where it is found that tempdb has surpassed 500GB in the dead of night.

Requirements Analysis:

We know that if you restart the SQL Server,tempdb, it will be automatically recreated, bringing the tempdb back to its original size. However, this is a production environment and it is not allowed to restart SQL Server.

Try:

Direct contraction of tempdb is always unsuccessful.

USE [tempdb]

GO

DBCC SHRINKFILE (Numbtempdev', 0, TRUNCATEONLY)-frees up all available space

GO

DBCC SHRINKFILE (Numbtempdev', 500)-shrinking to 500MB

GO

Solution:

In order to enhance the performance of tempdb, SQL Server 2005 and later versions will cache some IAM pages for future reuse. In this case, the IAM page must be released before its corresponding page can be released. Therefore, with DBCC FREESYSTEMCACHE, all unused cache entries are released from all caches, and then the tempdb is shrunk.

USE [tempdb]

GO

DBCC FREESYSTEMCACHE ('ALL')

GO

DBCC SHRINKFILE (Numbtempdev', 500)

GO

Finally shrunk to 500 MB. Success!

For DBCC FREESYSTEMCACHE, please refer to https://technet.microsoft.com/zh-cn/library/ms178529.aspx

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report