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

What should we do if the Tempdb space in SQLServer grows abnormally and occupies a lot of space?

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

Share

Shulou(Shulou.com)05/31 Report--

What to do about the abnormal growth and occupation of Tempdb space in SQLServer? I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

I. problem phenomenon

We have a mass production SQLServer that issues an out-of-disk space alarm in the middle of the night. When I log on to check, I find that tempdb has exceeded 500GB.

Second, the reason analysis

After communicating with AP user, AP user told us that there was an abnormal growth of tempdb due to a problem with AP logic.

III. Solutions

1. If the SQL Server,tempdb can be restarted, it will be recreated automatically, thus returning the tempdb to its original size. But the mass production environment should not be restarted unless it is a last resort.

2. Shrink tempdb directly (but never succeed).

(1) order

USE [tempdb]

GO

DBCC SHRINKFILE (Numbtempdb.mdf', 0, TRUNCATEONLY)-frees up all available space

GO

DBCC SHRINKFILE (Numbtempdb. MDF', 500)-shrinks datafile to 500MB

GO

DBCC SHRINKFILE (Numbtemplog.ldf', 10)-shrinks the log to 10MB

GO

(2) graphical interface

3. If the tempdb cannot be shrunk, you can use the following methods to deal with it before shrinking.

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 (Numbtempdb.mdf', 500)

GO

After reading the above, have you mastered the method of abnormal growth and occupation of Tempdb space in SQLServer? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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