Do i commit inside a loop when using a task Queue, or is it better to commit outside the loop and pass a ID to the Task Queue?

0
Hi there   We are creating many transaction lines inside of a loop. We create the transaction lines add them to a list and then commit the list once the loop has been completed. We trigger task queues inside the loop that need the transaction line as an input parameter, but the transaction line needs to be commited for the task queue to work. .   What would be the best solution for the performance of the system?   1) Just commit the transaction line inside the loop so the task queue does not break. The upside to this is we dont have to retrieve the transaction line as we have it as a input parameter. The transaction line table is massive.   2) Dont commit the transaction line in the loop and just pass through the transaction line ID. With the ID we can retrieve the transaction line from the database as the Task Queues only triggers once the master microflow is complete.    What will be best to do? or is there a better way? The transaction table has 100 million plus lines so we try to retrieve/commit as little as possible.   Regards, Patrick
asked
1 answers
1

Hello Patrick Gerardi,

 

If these are your two options then I would go for the second option, because committing your transaction within the loop directly will lead to performance problems.

However, there are maybe some extra steps you can take:

 

1. Can you process the transaction lines in separate batches and separate actions for example 100 * 10 000 or 1000 * 1000

2. If not try at least to split them in batches within the same action

3. If you do option 2 put an Index on the table ID(but only if you read/retrieve actions are outnumbering the create/delete actions

 

Hope this helps,

 

Good luck!

 

 

answered