TempDB

 

 

 

 * TempDB will not AUTOSHRINK, and you cannot set TempDB to AUTOSHRINK.
 * The tempdb size is reset to the last configured size after each restart.
 * It is safe to run shrink in tempdb while tempdb activity is ongoing.
   (single-user mode / no current tempdb activity)
 * By default, the tempdb database is configured to autogrow as needed.

Although the file sizes are listed as 30GB, they may be filled with Empty Space and not actually contain 30GB of file size. TEMPDB would have grown to 30GB at some point because it needed that much space for some certain queries.

# 8Kb pages
SELECT name, size
FROM sys.master_files
WHERE database_id = DB_ID(N'tempdb');

做法

# not require a restart of the sql server (individual files)
DBCC SHRINKFILE(logical_filename, size_in_MB)

# 10% of free space at the end of the file(current usage)
# check usage first: sp_spaceused
DBCC SHRINKDATABASE(tempdb, ‘target_percentage_of_free_space’);

# Management Studio
right mouse clicking the tempdb database and choosing Tasks->Shrink

Remark

 

 

 

 

 

 

 

 

 

Creative Commons license icon Creative Commons license icon