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)

Batch job Performance improvement

(0) ShareShare
ReportReport
Posted on by

Hi,

I have around 3 million records in a table. I am performing some operation and check validation and then insert data into my custom table but it takes around 40 min to complete the execution. Is there any way to run batch job speedily by any mean?

Any help will be highly appreciated. Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    Hi, there are many ways to speed up the batch job, but you have to give us more information so that we can help you instead of trying to guess. Share as much information as possible.

    Have you scrutinised the design of the code? Perhaps the design can be modified to increase the performance. Have you used the trace parser or code profiler tools? These tools will help you pin point the bottle necks like missing indexes and so forth.

  • Community Member Profile Picture
    on at

    Hello Anton,

    thanks for your reply. I didn't use any tool and the design is quite simple.

    This is how my batch job looks like:

    while select InventSerialId,ItemId from InventSerial

       join inventDim where

       inventDim.inventSerialId == InventSerial.InventSerialId

       join InventLocationId from InventLocation where

       inventDim.InventLocationId == InventLocation.InventLocationId

       {

           inventDim.inventSerialId= InventSerial.InventSerialId;

           inventDim.InventLocationId = InventLocation.InventLocationId;

           inventDimParm.initFromInventDim(inventDim);

           InventOnhand = InventOnhand::newParameters(InventSerial.ItemId, inventDim, InventDimParm);

           InventQty = InventOnhand.availPhysical();

           if(InventQty>0)

           {

    // insert data into custom table

           }

       }

  • Verified answer
    Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    Hi, the code is checking every single record if there is any physical inventory. I don't see a safe way of reducing the number records selected in the main query because it's using the InventOnHand class to check the inventory level. In some cases it is possible to reduce the total amount of iterations by limiting the data as much as possible, in this case you would only select items with where physical inventory is greater than 0, but I don't recommend doing that in this case.

    Because you mentioned it's a batch job, I assume that your code is executed on the server tier.

    Inserting bulk records into a table like should always be done with a RecordInsertList. There is only one catch, you don't have the RecID available anymore of each created record for reference/foreign key purposes. RecordInsertList increases performance by accumulating the actual inserts instead of a single insert during each iteration in the loop.

    To really improve the performance, make use of parallel processing in batch. Your code can split the to be processed data into equal chunks and process them in parallel. This is a powerful feature of AX but it should be used with care. There is a lot documentation available online on how to do that.

    Also, I definitely recommend using the trace parser or the code profiler to help identify the performance bottle necks.

  • Rodolfo Recalde Profile Picture
    on at

    Hi Hafiz,

    So, check the considerations set wisely by Anton.

    Please, also check if there are missing index to improve performance, or if it is necessary to organize the existing index

    I Hope this Helps!

    Regards,

    Rodolfo Recalde.

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