Loop optimizations - Mendix Forum

Loop optimizations


In a lot of cases where a list of objects is retrieved and processed in a loop, associated data is retrieved within the loop. 


Retrieve orderlines and in the loop get the associated order

This results in many single retrieves in the database.

That can be optimizated by retrieving the assocated objects outside the loop so all associated data is already in cached.

Retrieve the orderline with the orders

Of cause this should not be done when a condition is checked in the loop and not all associated data is needed.



  1. Faster execution
  2. No changes needed


Disadvantage is that the associated objects are not garbage collected within the loop.

0 answers