We’ve developed some components within D365 that generate some data and inserts it into tables.
The approach taken leveraged the “select forupdate <tableBuffer>” methodology to insert data.
In profiling the SQL statements, I have noticed that the “select forupdate <tableBuffer>” performs a SELECT statement against the target table; if modified to “select firstonly forupdate <tableBuffer>”, it results in a SELECT TOP(1) statement against the target table. This was resulting in performance degradation, where applying an index against [dataAreaId, partition] was needed, with include columns on all the table fields.
I realize I’m probably doing something a bit incorrect here – I understand the “forupdate” clause would normally be used with a selection of record to actually update (i.e. “select forupdate <tableBuffer> where recId = <value>”).
I know for fact the data I am trying to input is an insert; there would never be a need for an update. Is there any change I can make to avoid having to apply these other indexes?
—————————— Curtis Watson StarTech.com London ON ——————————
Corey Vantilborg
Member
September 11, 2019 at 8:58 AM
Curtis,
Ā Ā Ā Ā You do not need to do the select forupdate when doing an insert.Ā Ā That example from Microsoft is poor,Ā it would select the entire CustTable for no reason.Ā
Ā Ā Ā Ā This would work just fine:
static void Job7(Args _args)
{
TCI_ScanningSetup scanningSetup;
scanningSetup.ItemBuyerGroupId = 'VMI';
scanningSetup.insert();
}
Regards, Corey
—————————— Corey Vantilborg ERP Analyst Tigercat International Inc. Brantford ON —————————— ——————————————-
vishal Dhawgaye
Member
September 25, 2019 at 5:04 PM
I agree with Corey, you don’t have to user ‘forupdate’ for insert operation. you can also use ‘insert_recordset’ and ‘update_recordset’ while updating bunch of records. This gives better performance than ‘select forupdate’.
Please note:
This action will also remove this member from your connections and send a report to the site admin.
Please allow a few minutes for this process to complete.
Report
You have already reported this .
Welcome to our new site!
Here you will find a wealth of information created for peopleĀ that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!