AX Performance: Insert vs RecordInsertList
Today I would like to show you the difference, performance wise, between a plain insert of a big set of data versus an insert via a “RecordInsertList” in AX. My example is based on Dynamics 365 fFO (AX7), but it would work the same way in AX 2012.
Setup the Insert vs RecordInsertList Test
First I created a new table for this test. I just added an integer and a string field, both fields also define an index for this table.
Next, I created a runable class to perform both insert operations against the database.
First the “normal” insert statement:
Per given row we would insert an id and a string value, nothing special here.
Next the “RecordInsertList“:
In contrast to the “normal” insert statement I defined a new “RecordInsertList” object and provided the table id of the “BulkInsertTable”. Instead of an insert in the for – loop, I just call the add method of the list and provide the table buffer in every iteration.
After the loop is finished, I call the insertDatabase method to get my records inserted to the database.
I added the complete code to the end of this post.
In my test I performed both operations with 10k, 100k and 1mio rows:
As you can see the “RecordInsertList” is significantly faster and should be used for inserting bulk data instead of the insert method. (Clearly overlooked that “timeConsumed” already adds units 😉 )