Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A very big size of tempdb

I have a spring project, when I start the server a named file 'tempdb' is created in the sql server directory, the size of this file is too big (reaches 8G) I like to know why this file is created? is there a way to reduce its size? Thanks in advance

like image 593
Akino Avatar asked Sep 14 '25 09:09

Akino


1 Answers

run this

-- use the proper DB
USE tempdb;
GO
-- sync
CHECKPOINT; 
GO
-- drop buffers
DBCC DROPCLEANBUFFERS; 
DBCC FREEPROCCACHE;
DBCC FREESYSTEMCACHE('ALL');
DBCC FREESESSIONCACHE;
GO
--shrink db (file_name, size_in_MB)
DBCC SHRINKFILE (TEMPDEV, 1024);
GO

Either, you can always restart whole Database (like service restart), it will also drop the tempdb.

like image 124
matson kepson Avatar answered Sep 15 '25 22:09

matson kepson