web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Can I drop/delete TempDB Tables that AX has created

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I'm a DBA  working with AX for the first time.

I've noticed that application creates a lot of TempDB tables, and due to a lot of the code it doesn't delete most of the tables it creates (i.e the devs never built cleaning up routines in the code). This is creating a big problem because these tables start to eat into the memory of SQL, and take memory that could be used by the buffer pool (i currently have 300k temp tables and growing).

I spoke to one of the AX devs who advised that if AX needs to use a temp table it will create one, and it won't use a previously created table. So from my understanding it is always creating temp tables when required, does what it needs to do, and finishes, doesn't drop the table, rinse and repeat.

But what i have noticed when looking at queries throughout the day, is that some queries are using temp tables that were created weeks ago.

My main questions are, if i delete one of these tables while it is not in use, and then a query runs that would've used that tempdb table. Will AX create a new table because it can't find the previous one, or would there be some error when the query runs, as it can't find the temp table it expects to be there?

The end goal for all of this is to create a routine that cleans out TempDB tables on a nightly basis.

Thanks

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    At least I would not recommend deleting them when the system (AOS) is running.

    It's pretty common to see runtime errors if SQL Server was down, and AOS services were not restarted - AOS is trying to access temp tables that don't exist anymore.

  • wrigh2uk Profile Picture
    5 on at
    [quote]

    At least I would not recommend deleting them when the system (AOS) is running.

    It's pretty common to see runtime errors if SQL Server was down, and AOS services were not restarted - AOS is trying to access temp tables that don't exist anymore.

    [/quote]

    Hi Nikolaos thanks for the reply. 

    Would it be correct to assume that while AOS is running it is aware of the temp tables that exists, and may attempt to use those tables again?

    If so would the solution be to stop AOS services, delete the tables and then restart the AOS?

  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi wrigh2uk,

    I had a similar issue with temp tables in one of our customers and if I remember there was some kind of bug in AX. When you stop AOS service (properly) it will drop all temp tables from the database automatically, but it will take a lot of time (in my case it could take up to several hours to stop AOS). The fastest way it too forces AOSes to stop and restart SQL server instance.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans