I would like to set a value on all of the rows in an entity - I need to be able to have this execute as fast as possible.

0
I would like to set a value on all of the rows in an entity.  I am using an iterator which is very slow because when I look at the update in APM it's actually building an "In" clause and then udpating the value.  Is there a way to do a direct update to the rows using a SQL update without a custom Java Action?
asked
1 answers
1

Joshua

In your iterator, are you committing each object change?  If so, best practice is to not commit in the loop, but commit the list of objects in a single commit action after the loop is complete.  This may lead to better performance.  

This is because in Mendix, a microflow execution is maintained as a single 'transaction', so that all database changes can be rolled back in the event of an error somewhere in the microflow.  When you commit each object in the loop, Mendix keeps track of all of those changes so they can be rolled back if necessary.  When you are changing a lot of objects, this transaction gets very large and I have seen it cause performance issues on my server as more and more resources are consumed keeping track of database changes made previously in the microflow.  Committing changes after the loop has completed eliminates this issue, provided the commit is the last (or one of the last) activities in your microflow.

If that doesn't address your issue, perhaps some more info about what change you are making, how many objects are being changed, etc. would shed some more light on the slow performance.

Mike

answered