In Mendix 3 it is done like the picture below.
Clone item without optimization |
Explanation of the Microflow steps above. This example is limited to process 1000 records.
- Retrieve 1000 records
- For every record
- Create new record including update attributes, commit and refresh.
With Mendix 4, this can be improved. Performance improvement of 50% can be reached.
- Create a empty list
- Retrieve 1000 records
- For every record
- Create new record including update attributes (no commit and no refresh)
- Add new record to the list
- Finally commit the list including refresh.
- Refresh is needed when data needs to be displayed within screen.
In the example above the duration went from 9 seconds to 3.5 seconds.
When much more records needs to be processed it is advised to do it in batches. This can be done by setting the limit and offset at retrieve of the database entity. After the list is commited, clean the list and retrieve a new set of records from the database (see second activity in the Microflow).
Processing too many records at the same time can give memory overflow errors.
tip: When you have entities with more than 10 attributes it could be useful to use the Java clone function within the community commons from Mendix the App Store.
No comments:
Post a Comment