Update_recordset

Hi All,

I am trying to use update_recordset to update the records of my table but even then it’s very slow. I have also overridden and have some logic added in the update method of my table. Is this the reason why it is slow?

Any other way to increase the performance.

Regards,

Abhishek

Hi abhishek,

If you have overridden and have some logic added in the table update method, then in this case Update_recordset falls back to a classic looping construction, updating records one by one just as the normal table.update() is done. So in this as usual it will fetch and update records one by one.

I hope i cleared your query to some extent.

Thanks
Nitish

Hi Nitish,

Thanks!!!.

So I can use table.skipdatamethods(true) before using update_recordset to restrict calling of update methods correct?

Regards,

Abhishek

Hi abhishek,

Using table.skipdatamethods(true) will the fastest but this will skip the code on table update method and that logic will not be executed. An other thing that will cause update_recordset to be converted to record per record updates is when the database log is configured for that table in AX .

Thanks

Nitish.

Nitish is right - and you could have found the same simply by reading the documentation for update_recordset.

Also don’t forget that there may be more reasons why things are slow.

Hi Nitish,

Yes I know that my logic in update will not be called if I use skipdatamethods. But that is ok for me as the field I need to update will not affect my logic in update in any case.

Anyways I will check for database log you mentioned.

Thanks,

Abhishek

I know this thread is rather old, but I’m running into similar scenario.

Whenever I stumble on a sales line with specific flag, I need to update all other sales lines on the same order with serial number dimension from my line. In salesLine.update() method I call a custom method, which looks like this:

public server static void MyCustomMethod(SalesLine _salesLine)
{
    salesLine           salesLineUpd;
    InventDim           inventDim;
    
  if ( _salesLine.MyField )
  {
    inventDim = _salesLine.inventDim();

    salesLineUpd.skipDataMethods( true );

    ttsBegin;

    update_recordSet salesLineUpd
    setting PER_ChairSerialNo = inventDim.inventSerialId
    where salesLineUpd.SalesId == _salesLine.SalesId
    && salesLineUpd.RecId != _salesLine.RecId; // update every other line with serial id

    ttsCommit;
  }
}

I have 2 environments with exact same X++ code, binaries and CU level.

So, following suggestions in this thread, the update_recordSet is not chaining a call to salesLine.update() only in one of the two environments. However, it surprisingly does so in another environment.

My question is, despite skipDataMethods(true), what else might force the call to salesLine.update() in one of my environments?

P.S. - Sorry, I keep editing my post. Now it’s final :slight_smile:

There are several things that can cause the fallback to row-by-row operation, such as database logging (more in documentation), but I would still think that skipDataMethods() means skipping data methods. But maybe we’re wrong and it actually means that it just doesn’t take data methods into account when considering whether to switch to row-by-row processing and when it does, it calls data methods as usual.

It’s something you can test to be sure how it works.

Thanks Martin! You’ve just nailed it. Database logging for updates on SalesLine table was active in one of the environments which was thus falling back to record-by-record update. You rock!