TempDB

  • Comments posted to this topic are about the item TempDB

  • Basic question, but still good one.

    - SAMJI
    If you marry one they will fight with you, If you marry 2 they will fight for you 🙂

  • I got it right, but it was a coinflip. You can actually run DBCC CHECKALLOC and DBCC CHECKCATALOG on tempdb. You will not get an error, but on the other hand, nothing will actually be done.

    Even Books Online seems unsure about this subject. The reference given in the explanation does indeed state that these commands can't be run on tempdb. But the topics on DBCC CHECKALLOC and DBCC CHECKCATALOG themselves say it can be run - this is the exact quote from DBCC CHECKALLOC (http://msdn.microsoft.com/en-us/library/ms188422.aspx):

    "Note

    In SQL Server 2005 and later, running DBCC CHECKALLOC against tempdb does not perform any checks. This is because, for performance reasons, database snapshots are not available on tempdb. This means that the required transactional consistency cannot be obtained. Stop and start the MSSQLSERVER service to resolve any tempdb allocation issues. This action drops and re-creates the tempdb database."

    The DBCC CHECKCATALOG topic (http://msdn.microsoft.com/en-us/library/ms186720.aspx) has a similar note.

    To me, this says that you can run the command. But nothing will happen.

    When deciding whether the author of this question intended to ask if we can execute the command on tempdb and not get an error (yes, we can), or if we can get SQL Server to actually perform the checks that these DBCC commands do on tempdb (no, we can't), I went with the latter.

    (Steps aside and makes room for the angry comments by those who picked the other option and now "want their point back")


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Hugo Kornelis (8/20/2010)You can actually run DBCC CHECKALLOC and DBCC CHECKCATALOG on tempdb. You will not get an error, but on the other hand, nothing will actually be done.

    Which version is that on? With 2008 I get

    The check statement was aborted. DBCC CHECKALLOC cannot be run on TEMPDB.

    The check statement was aborted. DBCC CHECKCATALOG cannot be run on TEMPDB.

  • Toreador (8/20/2010)


    Hugo Kornelis (8/20/2010)You can actually run DBCC CHECKALLOC and DBCC CHECKCATALOG on tempdb. You will not get an error, but on the other hand, nothing will actually be done.

    Which version is that on? With 2008 I get

    The check statement was aborted. DBCC CHECKALLOC cannot be run on TEMPDB.

    The check statement was aborted. DBCC CHECKCATALOG cannot be run on TEMPDB.

    I get the same message (SQL 2005). But those are informational messages, not error messages.

    BEGIN TRY;

    DBCC CHECKALLOC (tempdb);

    DBCC CHECKCATALOG (tempdb);

    PRINT 'No errors';

    END TRY

    BEGIN CATCH;

    PRINT 'Error';

    END CATCH;

    The check statement was aborted. DBCC CHECKALLOC cannot be run on TEMPDB.

    DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    The check statement was aborted. DBCC CHECKCATALOG cannot be run on TEMPDB.

    DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    No errors

    So you can not get SQL Server to check allocation or catalog in tempdb, but you can run these commands. Hairsplitting, I know - but when I answered the question, I found mysself wondering what interpretation the author would use.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • SQL 2000, DBCC CHECKALLOC & DBCC CHECKCATALOG runs ok

    Mis-read the 'Perform' in the question and missed the right choice.

    Glen Parker 🙂

  • I guess if we really want to split hairs and get technical, it is possible to drop tempdb. Stopping and starting the SQLService or rebooting the server will result in tempdb being dropped and recreated.

  • Great question....I am not a DBA and this is sort of a DBA question. That is why I love QoTD. It makes me explore areas that are not in my primary skill set or a part of my daily concern.

  • Was sure about other three answers but not sure about

    Running DBCC CHECKALLOC or DBCC CHECKCATALOG

    I executed them on all SQL Server versions and it could be executed successfully on SQL Server 6.5, SQL Server 7 and SQL Server 2000.

    But 2005 and 2008 throws error.

    The check statement was aborted. DBCC CHECKCATALOG cannot be run on TEMPDB.

    The check statement was aborted. DBCC CHECKALLOC cannot be run on TEMPDB.

    DBCC execution completed. If DBCC printed error messages, contact your system administrator.

    SQL DBA.

  • Hugo Kornelis (8/20/2010)


    (Steps aside and makes room for the angry comments by those who picked the other option and now "want their point back")

    Nope. No angry comment 🙂

    It is how you interpret 'performed'. On SQL2K it performs and produces output, which may indicate it did nothing but it still performed in a way.

    Oh well, C'est la vie. 😀

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Good question, thank you. I got it wrong because sadly I did not read the question carefully enough, and performed was the key. Running it does not produce any error, i.e.

    use tempdb;

    go

    dbcc checkalloc with no_infomsgs;

    go

    reports "Command(s) completed successfully."

    The question asked performed not ran, and BOL's verdict is clear:

    In SQL Server 2005 and later, running DBCC CHECKALLOC against tempdb does not perform any checks.

    Oleg

  • Thanks for the question.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • It has more that can't perform like:

    Adding filegroups and Backing up or restoring the database

  • Interesting question on the TempDB. Back to basics and the url below under the 'Restrictions' states all the facts too.

    URL: http://msdn.microsoft.com/en-us/library/ms190768.aspx

    Thanks

Viewing 14 posts - 1 through 13 (of 13 total)

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