23
Views
3
Comments
Aggregates or Simple Queries 
Question

If I am good in writing SQL queries. What would be more preferable to use either it is OS aggregates or simple queries (DML)? What is the best practice and which will be faster?

mvp_badge
MVP
Rank: #19
Rank: #1592

Hi Daniël,

Thanks for these useful links. I will read these and get back to you, if have some more question.

Best Regards,

Sachin


mvp_badge
MVP
Rank: #2

Hi Sachin,

Use Aggregates when you can. The OutSystems Platform optimizes the attribute output, which increases performance. Also, they are automatically refreshed when you refresh references for changed Entities.

Use SQL in the following cases:

  • if you need features not supported by Aggregates, like subqueries, WITH common table expressions, IN, etc.;
  • with large, complex queries with lots of complex joins like nested inner joins (possible in Aggregates, but one loses overview quickly);
  • for UPDATE and INSERT queries.