Performance issues in Mendix apps aren’t usually caused by one big mistake, but can be a result of lots of small decisions made over a period of time. As an application evolves and grows in functionality, it naturally takes on more data and more sophisticated logic. Mendix apps start out fast and responsive, with pages loading instantly and logic running smoothly but over time, performance can quietly become an issue.
This is completely normal and the good news is that most performance issues in Mendix applications aren’t caused by the platform itself but by common design and structure choices. They aren’t a result of bad development or platform limitations, but the gradual build-up of design decisions. There are many ways we can improve Mendix application performance and in this blog post, I will be focusing on the areas that consistently make the biggest difference.
Performance problems are usually gradual and a key lesson in performance optimisation is understanding that it progresses incrementally. Performance issues are easy to ignore early on but, if left unchecked, these small delays can add up and start to affect the overall user experience. It has been found that over 50% of users abandon apps that take longer than 3 seconds to load, with each extra second of delay reducing task completion rates by around 7%. This is why it is crucial to keep app optimisation in mind throughout development and on an on-going basis. Speedy apps = happy users!
When we observe this, the best approach is to pause and examine three core aspects: how the app retrieves data, executes its logic, and renders pages.
#1 Data retrieval
As we build apps that handle important data, it is easy to fall into the trap of thinking “it’s safer to retrieve all the data, just in case”. Whilst this isn’t a bad instinct, in practice it often leads to unnecessary data being loaded which can quickly impact performance as our applications grow.
Common mistakes with data retrieval:
- XPath queries are too broad
- Pages load full datasets “just in case”
- Loading related objects through associations when the page or logic doesn’t need it
Improvements:
- Limit the number of objects returned in list and data views
- Review associations and ensure the most appropriate path is being taken, not the most convenient
- Be specific with XPath constraints and avoid retrieving “everything”
Using indexes can be a great way to improve performance. Without an index, the database may need to scan every record in a table to find matching results. By applying an index to attributes which are frequently used in XPath constraints, the database will be able to find the data it needs much more efficiently. It is worth noting that indexes are best used when data is read more than it is written. If data changes frequently, it’s worth focusing on other optimisation methods (Image 1).
Top tip: Within Mendix Studio Pro, make use of the Find Advanced feature (Ctrl + Shift + F), searching specifically for XPaths. This will allow you to quickly find the large XPaths in your applications and make them more efficient if applicable (Image 2).