Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Monitoring the TempDB

Posted on by

Does anyone know a good way to monitor TempDB usage?  We have a highly customized system and TempDB is used heavily for batch processes, SSRS reports, massaging data for inquiry screens, among other things.  Occasionally we get an error like this: 

Cannot execute a data definition language command on YOUR TEMP TABLE (YourTableTmp).
The SQL database has issued an error.
Object Server 01:
[Microsoft][SQL Server Native Client 10.0][SQL Server]The transaction log for database 'tempdb' is
full due to 'ACTIVE_TRANSACTION'.
INSERT INTO tempdb."DBO".t110862_3F7911B1F0464F7898FCF9566F1D2F7E (Column1, Column2, Column3, ...) SELECT ...
session 27

I can see from this statement which query failed due to the TempDB tranasction log filling up but I'm wondering if there's any way to know what processes have contributed a significant amount of data.  I've added some additional logging to this particular process to identify how many records are being written and it doesn't seem like a lot so my feeling is we have an accumulation of processes hitting our TempDB and filling it up.  I wonder if anyone has any tips or tricks to figure out who is filling up the TempDB in a system that's using TempDB all over the place?  Any suggestions greatly appreciated!

*This post is locked for comments

  • Greg's Mom Profile Picture
    Greg's Mom on at
    RE: Monitoring the TempDB

    Thank you Ievgen, Andre, and Brandon!  This is exactly what I was looking for.  I will look into the DMVs, the configuration link, and the version store.  I'm not too familiar with them since our infrastructure and DBAs handle most of that stuff but I will review and pass these on to those guys and see if we can figure out what's going on.  Thanks again!

  • Verified answer
    Brandon Wiese Profile Picture
    Brandon Wiese 17,786 on at
    RE: Monitoring the TempDB

    Brawndo,

    Assuming you don't have basic configuration issues with your TempDB, i.e. too small with not enough auto-expand, insufficient storage on the hosting volume, not enough files per the recommended configuration, sufficiently fast storage to handle you workload, etc., you could have one of two types of problems.

    First, and this is arguably the more common, you could simply be generating a temporary table of such size that no amount of TempDB could do the job.  For example, a ledger transactions SSRS report run wide open against hundreds of millions of transactions is just going off the rails, plain and simple.  The statement that "crashed" may not be the statement ultimately responsible.  In other words, the error message may indicate one statement failed to find the space it needed, but the problem is another statement entirely that consumed, or more likely is still consuming, the TempDB space, and when the transaction is terminated a bunch of space is freed relatively instantly.  If your TempDB is really filling up in this way, with actual data/index/log pages in temporary tables, you should be able to monitor this easily with built-in Windows performance logging and see it on Disk used reports against TempDB.

    Second, and this is probably less common but far more insidious, you could be suffering from a version store issue due to a long running transaction, even if that transaction is read-only.  If you're not familiar with the version store and how TempDB is used to support the version store, take an hour and do some reading.  In particular, note that the version store does not make TempDB appear full on Disk usage reports.  Also, depending on your system throughput, the version store can consume a truly amazing amount of storage in a very short time.

    Just to give you some numbers.  I have a production instance with 64 GB of TempDB sitting on 100 GB dedicated volume, and our system idles at about 2,000 Batch requests/second with spikes to 30,000.  On a normal day, TempDB never exceeds 5% full according to SQL Server metrics, and never auto-expands.  However, we went through a bad spell a year ago where TempDB would fill, expand to fill the dedicated volume, and bring everything crumbling down, over the course of about 45 minutes.  That's 0 GB to 100 GB in under an hour, which was much faster than any of our drive space alerting software was checking for, and so it kept blindsiding me.

    The problem was the version store and long running transactions.  The version store can be monitored with DMV's, and long running transactions are perhaps even easier to monitor, and an open transaction older than say 5 or 10 minutes may deserve your attention, though a few may be normal too (large journal postings, etc.).

    In any case, this is a side of TempDB that you don't hear or read about very often, and particularly not in response to questions like yours even though it's highly relevant.

    Good luck and hope this helps!

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: Monitoring the TempDB

    Hi Brawndo,

    The temp DB is used heavily by Dynamics AX and SQL management. If the log is regularly full, you have to review SQL settings. Do you have the correct size? Have a look at the documentation for some best practices: docs.microsoft.com/.../configure-sql-server-and-storage-settings

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Monitoring the TempDB

    You can use DMV to find session ID and query www.mssqltips.com/.../track-sql-server-tempdb-space-usage

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans