Hey Anna,
OQL is more efficient for complex queries than using multiple retrieves and processing results in memory. It handles joins more effectively by combining multiple entities in a single query.
OQL excels with large data sets, leveraging database-level optimizations, reducing the amount of data transferred to the Mendix runtime. It uses only the necessary fields to retrieve data, which reduces memory usage and increases performance.
Normal retrieves using XPath are simpler and more intuitive for straightforward data retrieval, where you just need to fetch objects based on basic conditions. They're easy to set up and maintain and are usually sufficient for basic CRUD operations and common data access patterns.
Check those questions:
- https://community.mendix.com/link/space/databases/questions/139053
- https://community.mendix.com/link/space/databases/questions/138677
I hope it helps,
Ricardo Pereira