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

Management reporter security query - performance

(0) ShareShare
ReportReport
Posted on by

Good Morning,

We are using AX 2012R3 CU9 with Management Reporter CU16.

The issue we have is the performance of the query reading security information from AX to MR. It is executing every 5 minutes and reading a lot of data (IO up to 1000 MB/sec), returning over 110000 records. Here is the beginning of the query:

"select T.USERKEY, T.NAME, T.ALIAS, T.DOMAIN, T.SECURITYID, MAX(T.GENERALLEDGERROLETYPE) GENERALLEDGERROLETYPE, T.COMPANYKEY, T.ISENABLED
from (
select UI.RECID USERKEY, UI.NAME, UI.NETWORKALIAS ALIAS, UI.NETWORKDOMAIN DOMAIN, SID SECURITYID,
CASE st.AOTNAME
WHEN 'SysSecSecurityMaintain' THEN 5
WHEN 'LedgerBalanceSheetDimMaintain' THEN 4
WHEN 'LedgerFinancialJournalReportBGenerate' THEN 3
WHEN 'LedgerBalanceSheetDimPrintGenerate' THEN 3
WHEN 'LedgerViewFinancialStatement' THEN 2..."

I read multiple posts about that query. Unfortunately the only solution was to reduce the frequency of running that update:

http://www.summitgroupsoftware.com/blog/management-reporter-data-mart-synchronization-frequency

The name of the task responsible for that in MR setup tables is 'AX 2012 Companies to Company'. Do you know if this task is only performing the user security query or some other information? I wonder if reducing the frequency to (for example) 1 hour would be a good idea or can it influence other areas that security. 

Maybe someone has more information what exactly is executed under: 'AX 2012 Companies to Company'?

Or maybe do you have other solutions for this heavy query?

Best regards,

Maciej

*This post is locked for comments

I have the same question (0)
  • guk1964 Profile Picture
    10,888 on at

    I don't think is necessary to sync users every 5 minutes. However when you at making changes in Ax financials at month end  you may want to e those reflected in your report without delay.

    There was recent post about adding indexes via the  AOT to improve MR performances .

    You might also check whether there is any sql maintenance being done on the MR database.

  • Community Member Profile Picture
    on at

    Thanks Magic,

    The thing is that I don't want to change the frequency of all tasks but only 'AX 2012 Companies to Company' which contains the heavy query I posted. But I don't know if there is more queries behind this task. In total there are like 15 tasks in MR synchronizing the data from AX.

    Regarding indexes - yes, we made some improvements in indexes but still query is heavy.

  • Suggested answer
    guk1964 Profile Picture
    10,888 on at

    One tip from my files that may help (which  I vaguely recall  was a comment note, I think from Tommy Skaue, but I don't have a link)  :

    " ...... some of the long running queries from Management Reporter towards the AX2012 OLTP is that it ometimes pulls the entire DirPartyTable when it really only wants the companies.

    So try adding  a WHERE clause on INSTANCERELATIONTYPE to select only  those with the value of 41 (which narrows it down to the instance “CompanyInfo”)"

    That seems to fit your situation and should be quick and easy to test. 

  • Community Member Profile Picture
    on at

    I had an issue with the query. It is used to take 15+ hours to execute ! After I enabled SQL trace flag 4199, the same query took less than 40 minutes to execute.

    Otherwise I suggest increasing the interval. 

  • Suggested answer
    guk1964 Profile Picture
    10,888 on at

    The trace flag is a query optimiser that many dbas would set globally in prior versions of SQL. In many cases to take advantage of an enhancement or a fix, the T4199 may be  a necessity. Be aware however that is set globally then there is no Per-Session Override option.

    It depends on your SQL version. Trace flag 4199 was used to collect hotfixes that were intended to become on-by-default in a future release, whereas other trace flags were used for situations in which a fix was not intended to become on-by-default in current form.

    Starting with SQL Server 2016 RTM, the database COMPATIBILITY_LEVEL setting is used to enable trace flag 4199-related hotfixes on-by-default

    So its no  more needed with SQL Server 2016, but is useful on earlier versions.

    In SQL Server 2016, It is automatically included when you change the COMPATIBILY LEVEL to 130:

    USE [master]

    GO

    ALTER DATABASE [MyDatabase] SET COMPATIBILITY_LEVEL = 130

    GO

     

    Going forward, Trace Flag 4199 will be reused as a bucket for future query optimiser hotfixes.

    Database Scoped Configurations, is one of the bestnew features in SQL Server 2016. It  gives you the ability to make several database-level configuration changes for properties that were previously configured at the instance-level.  In particular, the QUERY_OPTIMIZER_HOTFIXES database scoped configuration allows you to enable query optimiser hotfixes at the database scope whereas in previous versions of SQL Server you were restricted to enabling query optimiser hotfixes at the query, session or global scope using the logical equivalent Trace Flag 4199. 

    The T-SQL for this is:

    USE [MyDatabase];
    GO
    ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = ON;
    GO

    (If you do find a unexpected/poor plan, then use the Query Store to analyze and force a plan -  see  KB974006)

  • Community Member Profile Picture
    on at

    Thanks Magic,

    Well, this should improve the performance, but I have no idea how to change the query. As far as I know this is something embedded in MR. Does anyone know if this is possible to modify?

    BR,

    Maciej

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

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans