AX 2009 - "crosscompany" VS "changecompany" performance issues

Hi everyone

While analyzing some performance issues that we are having with our system, I have come across a code in standard AX 2009 which comes up quite often as a performance bottleneck. Table SpecTrans has a method vendTrans() which for some reason uses crosscompany keyword to run a select statement - however due to how it’s built, it will always be only 1 company in this so called “cross company” selection. We know that crosscompany is handy when you need to do a selection across several given company accounts, however in case if it’s only one company to select from then in my opinion changeCompany() could also be used here and probably with an even better outcome. As we know calling crosscompany results in an SQL select statement that has an IN () keyword which might be a possible bottleneck especially if you have lots of companies in your AX.

So my question is - would anyone have an idea as to why did Microsoft decide in favor of using crossCompany for a one single cross company selection instead of using changeCompany() ? I have lots of SQL trace logs where I can see that execution of that awkward crossCompany:ABC1 takes even up to half a minute in such a relatively short method of SpecTrans.vendTrans(). I would be keen to change this code to use changeCompany() instead. But would you see a problem with that? Could I be missing some point there?

Thanks,

Janis

This has been fixed in AX 2012 R2, so you should be good to have that change to changeCompany().

the same is with \Data Dictionary\Tables\SpecTrans\Methods\custTrans

\Data Dictionary\Tables\SpecTrans\Methods\custTransOpen

\Data Dictionary\Tables\SpecTrans\Methods\vendTransOpen

Perfect, Kranthi ! I’ll give it a try!