|
Post by tjvrdev on Apr 28, 2020 18:05:33 GMT
I'm currently working with a List of Machine Entries that gets added to a DB. My logic is currently looping through the list of Machine Entries & inserting each entry to the db. My test data has 112 Entries and it takes about 1.4 seconds for it to complete. On the production side, there are around 500 Machine Entries and the same logic causes a tremendous amount of lag. I'm looking at optimizing this logic & I believe instead of looping through each entry and calling insert. I should build a large sql string containing the entries & using a single insert (or divided into insert chunks). Is there any example code showing what a sql insert string would look like when manually inserting the class object without passing the actual object?
Edit: Well I learned about transactions and revisited the transaction section of the documentation and found I can just simply pass in the list in the DB.InsertAll() method. Super easy and lowered processing time from 1400 milliseconds to 70 milliseconds.
|
|
|
Post by echo17 on Apr 29, 2020 10:44:22 GMT
Awesome! I'm glad you found a solution. Thanks for the update.
|
|