x
login about faq Site discussion (meta-askssc)

Move tempdb

Can I move the tempdb database to a separate drive and leave the rest of the system databases (master, msdb) on a separate drive? Please advice, I would like to apply this to the production database so that the system does not shutdown.

more ▼

asked Oct 23 '10 at 03:55 PM in Default

Chitra gravatar image

Chitra
148 10 15 19

@user-489 if my answer got you what you needed, do you mind checking the check box to mark it as the answer.

Oct 25 '10 at 12:05 PM Tim
(comments are locked)
10|1200 characters needed characters left

5 answers: sort voted first

Yes, use the alter database command. Of course change the drive letter and location in the script below to your naming standard and drive(s).

USE master  
 GO  
 ALTER DATABASE TempDB MODIFY FILE  
 (NAME = tempdev, FILENAME = 'e:\tempdb\datatempdb.mdf')  
 GO  
 ALTER DATABASE TempDB MODIFY FILE  
 (NAME = templog, FILENAME = 'f:\tempdb\datatemplog.ldf')   
 GO    

Then restart your sql service.

more ▼

answered Oct 23 '10 at 04:03 PM

Tim gravatar image

Tim
31.7k 23 32 116

Short and sweet.

Oct 23 '10 at 05:26 PM Blackhawk-17

Thank you so much for the quick response. I will be running the dry run in dev.

Oct 23 '10 at 06:49 PM Chitra

That is what we are here for. So many others have helped me out on here, it is nice to give back.

Oct 23 '10 at 06:59 PM Tim

@TRAD +1 I would like to add just one cent: it is a very good idea to have tempdb on the separate drive, and if there is a need to have more than one tempdb file then it is best to store each on the separate physical drive, so each file gets it own spindle. This implies that tempdb file(s) should never be on the same spindle with any non-system database files if possible.

Oct 25 '10 at 08:48 AM Oleg

Yes @Oleg (+1), and you might consider using a SSD for the tempdb.

Oct 25 '10 at 08:54 AM Mark
(comments are locked)
10|1200 characters needed characters left

Just to add...tempdb is recreated each time the SQL Service starts, hence why you have to restart after changing the locations, so be aware that the 'old' tempdb files will still exist in the original location once you have restarted.

These can be safely deleted once the 'new' tempdb is being used.

more ▼

answered Oct 24 '10 at 06:45 AM

Kev Riley gravatar image

Kev Riley ♦♦
46.1k 39 43 69

Good follow-up. Seeing the leftover files can be a bit misleading.

Oct 25 '10 at 09:27 AM KenJ
(comments are locked)
10|1200 characters needed characters left

Also, just to add, size the tempdb data files properly so they do not autogrow in tiny chunks every time causing unnecessary fragmentation. Same goes for the log file. Take into consideration that the log file can take some time to create at service startup if its large, as the database will zero-out the file.

more ▼

answered Oct 25 '10 at 12:33 PM

ozamora gravatar image

ozamora
1.4k 2 3 5

(comments are locked)
10|1200 characters needed characters left

Just one more note, 1 tempdb file per processor core is a myth. You can start with 1/4 and then go up with 1/2; needs to be tested.

more ▼

answered Oct 25 '10 at 12:42 PM

ozamora gravatar image

ozamora
1.4k 2 3 5

(comments are locked)
10|1200 characters needed characters left

I recently read that if your cores are less than 8 go with one per core, then if you have more than 8 start with 8 and increase in units of 4.

more ▼

answered Oct 03 '12 at 04:29 PM

Scotty gravatar image

Scotty
290 1 3 3

It depends... if you tie your cores up with I/O then they can't do other processing at the same time. Each workload will require analysis and a balance.

Oct 03 '12 at 05:46 PM Blackhawk-17
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1843
x43
x16

asked: Oct 23 '10 at 03:55 PM

Seen: 1399 times

Last Updated: Oct 03 '12 at 05:46 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.