Shrink TempDB
use tempdb
GO
SELECT name, size
FROM sys.master_files
WHERE database_id = DB_ID(N’tempdb’);
GO
DBCC FREEPROCCACHE — clean cache
DBCC DROPCLEANBUFFERS — clean buffers
DBCC FREESYSTEMCACHE (‘ALL’) — clean system cache
DBCC FREESESSIONCACHE — clean session cache
DBCC SHRINKDATABASE(tempdb, 10); — shrink tempdb
dbcc shrinkfile (‘tempdev’) — shrink default db file
dbcc shrinkfile (‘tempdev2’) — shrink db file tempdev2
dbcc shrinkfile (‘tempdev3’) — shrink db file tempdev3
dbcc shrinkfile (‘tempdev4’) — shrink db file tempdev4
dbcc shrinkfile (‘templog’) — shrink log file
GO
— report the new file sizes
SELECT name, size
FROM sys.master_files
WHERE database_id = DB_ID(N’tempdb’);
GO
sp_WhoIsActive to get to the root cause of this. It was really clear once I filtered down to the timeframe in question and sorted by the tempdb allocation column
DMV sys.dm_db_task_space_usage
Also, if you have not already done so, you should enable Query Store for your database. (Not tempdb, but the one that is 100 GB.) When tempdb gets "full", you can check what has been the most resource-consuming queries the last hour, and then run sp_recompile one of tables in the top query, to see if that helps.
https://www.sqlserverblogforum.com/dba/tempdb-database-is-full/
Comments
Post a Comment