TempDB

  • Hi,

    Our AD team ran a job and the job did not complete.  I checked the error log and found this message  " Could not allocate new page for database tempdb. There are no more pages available in filegroup 'DEFAULT'. "  Do I just delete some files/objects or add additional files.  Please let me know.

     

    Thank you.

  • What ever the process/job you ran requires the tempdb space and your tempdb ran out of space...

    All temporary tables created in tempdb will be dropped at the end of the session unless you created any permanant objects...

    You need more space on drive to expand tempdb when it is needed...

    Don't create tempdb on c:\ by default it creates on c:\...

     

    MohammedU
    Microsoft SQL Server MVP

  • and use the below script to move tempdb to other drives

    alter database tempdb modify file

         (name='tempdev',filename= 'E:\MSSQL\data\TempDB\tempdb_data.mdf')

    alter database tempdb modify file

         (name='templog',filename= 'C:\MSSQL\data\TempDB\tempdb_log.ldf')

    This requires server restart to take effect..

     

     

    Shekhar


    Thanks ,

    Shekhar

  • Another way to get your error message is if the auto grow parameters on tempdb are very small.  This also applies to all other databases. 

    When SQL decides it needs to grow a database, it will only trigger autogrow once per space request.  If SQL needs 10 MB for an object but your autogrow only allows growth of 1 MB, the database will grow by 1 MB but the space request will fail giving the message you report.  When SQL runs out of space it cannot detect the difference between a) an object set to never grow; b) an object cannot grow because the disk is full; c) the autogrow parameter is smaller than the space request.  All three conditions give the same SQL error message.

    You need to review the size of tempdb, and make sure the initial size is big enough for your normal requirements.  If you start SQL with a tempdb of 1 MB and after a day it is 100 MB, then you need to set the initial size of tempdb to 100 MB.  You should then set the autogrow parameters to give a sensible growth amount for the actual size of tempdb.  E.G. a tempdb of 100 MB should be set to grow by 10 or 20 MB, but a tempdb of 50 GB may need to grow by 1 or even 5 GB.

    If you do a ALTER DATABASE to move the tempdb files (see BOL), you only need a SQL Server restart, not a Windows reboot.  Do not detach or DROP tempdb, as this will stop SQL working and is very difficult to fix.

    Original author: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist - Archbishop Hélder Câmara

  • I'd also look into what caused the growth anyway - maybe the job needs to be batched or include checkpoints. I also beg to disagree about default location of tempdb being C: , not so, it goes wherever you define in the install process ( sql 2000 )

     

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • make sure to delete old tempdb files in original location after restart

  • Set a growth in MBs ratherr than specifying in Percent. Modify th changes in MODEL database so that tempdb gets created with that properties every time sql server gets restarted.

    Cheers,
    Sugeshkumar Rajendran
    SQL Server MVP
    http://sugeshkr.blogspot.com

  • ...Could not allocate new page for database tempdb....

    You may have been running into a file allocation timeout. Sqlserver only waits for a certain time to receive a "file extended" reply from the filesystem.

    If it detects a timeout it throws the error your mentioned.

    Behind the scenes, it may occur the extend actualy worked after the timeout. Then there's no need to take action, unless you want to know why the enlargement was needed.

    Also, check if the tempdb files grow by percentage or by actual sizes. Prefer the latter one.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Is there anyway - WITHOUT HAVING TO RESTART THE SERVER - to move the transaction log file and/or master files of 'tempdb' to another separate physical drive to boost performance? Thanks in advance. David

  • No,

    You can run the ALTER DATABASE TEMPDB script but it will not take effect until you restart sql server because tempdb recreated every time you restart sql.

    Note: Don't use MASTER file word... it is confused...either you say data file or mdf file...

     

    MohammedU
    Microsoft SQL Server MVP

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply