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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Query make my server very busy / slow

(1) ShareShare
ReportReport
Posted on by 125

Hi All

IN sp_whoisactive, I found a query which makes my server cpu busy and make the system slow. when I kill that specific query then there is no effect on any users. any body can guide what is the purpose of this query and how I can permanently kill this query for future.

<?query --
SELECT COUNT(T1.RECID) FROM CUSTTRANSOPEN T1 CROSS JOIN CUSTTRANS T2 CROSS JOIN CUSTTABLE T3 WHERE
(((T1.PARTITION=@P1) AND (T1.DATAAREAID=@P2)) AND (T1.DUEDATE<@P3)) AND (((T2.PARTITION=@P4) AND
(T2.DATAAREAID=@P5)) AND (((((((T2.TRANSTYPE<=@P6) OR (T2.TRANSTYPE=@P7)) OR ((T2.TRANSTYPE=@P8) OR
(T2.TRANSTYPE=@P9))) OR (((T2.TRANSTYPE=@P10) OR (T2.TRANSTYPE=@P11)) OR (T2.TRANSTYPE=@P12))) AND
(T2.AMOUNTCUR>=@P13)) AND (T1.ACCOUNTNUM=T2.ACCOUNTNUM)) AND (T1.REFRECID=T2.RECID))) AND (((T3.PARTITION=@P14)
AND (T3.DATAAREAID=@P15)) AND (T2.ACCOUNTNUM=T3.ACCOUNTNUM)) OPTION(FAST 5)
--?>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    First of all, you should never kill anything from SQL end.

    Do you have proper index and statistics maintenance on your SQL Server? Do you have the SQL Trace Flags enabled recommended for Dynamics AX?

    You should use the available tools at your disposal to identify who and why are running the slow performing statement, for example by using AX Trace collector and then checking the collected ETL file with the Trace Parser. Also you should check the query plan of the statement, to see why it is bad.

    Do you have any SQL disk I/O bottlenecks?

  • Rana Adil Profile Picture
    125 on at

    Hi Vilmos

    Thanks for replay

    that query was generated by AX AOS to DB Server, This query never end until I kill. this query consume my SERVER CPU and in multiple queries. you may look into the attachment.

    Index, flags and stats updated successfully there is not issue.

    8780.Count.jpg

  • Rana Adil Profile Picture
    125 on at

    In the above screen short first 4 or 5 queries are same there is not single character difference which cause CPU slow

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    The AX database has an sp_axwho stored procedure which could reveal that who is executing that specific query.

    Also you might find this helpful: blogs.msdn.com/.../finding-user-sessions-from-spid-in-dynamics-ax-2012.aspx

    With that you could find out if the process is triggered by a User in which case you could interrogate them on what are they doing, or if it is an AOS process then it might be coming from a batch process.

    Also consider capturing that AX trace and check the code/statement there...

  • Rana Adil Profile Picture
    125 on at

    Sorry Vilmos

    I cant get your point.

    SP_axwho is not any procedure in my DB

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    If the SP is missing then you probably should have bigger concerns about your database integrity.

    It should look like this:

    spaxwho.jpg

  • Rana Adil Profile Picture
    125 on at

    Thanks but I did not find any such SP in my DB

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Did you try finding the session explained in the blog post I have linked to get which user is running the query? That is a separate way from the stored procedure, it was just less convenient.

  • Prodware_SaM Profile Picture
    on at

    This Query shows the number of due CustTrans (only 1 row, 1 column = Count of RecIDs), it is shown in a small Widget. 

    This could also explain why you could kill that without that any User noticed that nor complain.

    As it is effictively like an innerjoin it becomes slow because statistics and index are not useful for the Query Engine.

    So Index and Statistic Maintenance might solve that. In our current Case 80-99% to 3% CPU Workload. 

    SaM / www.prodware.de

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

News and Announcements

Season of Giving Solutions is Here!

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#3
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans