×

Differences Between Aggregates and Server Actions in Data Retrieval

Differences Between Aggregates and Server Actions in Data Retrieval

Aggregates and Server Actions are pivotal components in application development in OutSystems. While both play similar roles in data retrieval and manipulation, they exhibit distinct differences in terms of optimization and functionality. In this article, we will explore the key disparities between Aggregates and Server Actions in OutSystems, highlighting the advantages of each and the ideal usage scenarios.

Why Aggregates are More Commonly Used:

Optimization of Data and Column Selection

One of the fundamental differences between Aggregates and Server Actions lies in the optimization of returned data. When using Aggregates, the results are tailored for the specific screen where they are displayed. This means that only the columns relevant to the table or list are retrieved, minimizing data traffic and enhancing application performance. On the other hand, Server Actions lack this native optimization; they return all columns from the data source. When there are many irrelevant columns, it’s advisable to implement an output structure to return only pertinent data, thus mitigating resource waste and exposure of sensitive information.

Usage of StartIndex

Another notable distinction is in the usage of the StartIndex parameter. When calling an Aggregate on a screen, you can define the StartIndex property to retrieve a subsection of results, effectively implementing pagination for tables. However, Aggregates within Server Actions do not include this functionality (if you want, vote for it in Ideas). Consequently, Server Actions might fetch more data than needed, requiring additional logic to manage pagination and indexes.

Then, why use Server Actions?

Security and Control

Server Actions possess several remarkable advantages, solidifying their fundamental role in data retrieval and manipulation. Firstly, they inherit all the benefits of a standard action. This includes the ability to validate permissions before data retrieval, track executed actions, and apply transformations (such as filters, calculations, and grouping) to data before export. These features add an extra layer of security and control to data retrieval and manipulation processes that a simple Aggregate cannot provide.

Flexibility and Reusability

Another point in favor of Server Actions is their flexibility to retrieve data from various sources beyond Aggregates, such as Advanced SQL queries or web services. Moreover, Server Actions can be reused across multiple scenarios. By utilizing Server Actions in various screens of the application, you can leverage pre-defined Actions for different screens and prevent logic duplication. This results in a more cohesive, modular, and easily maintainable architecture.

In conclusion, both Aggregates and Server Actions play critical roles in data retrieval and manipulation within applications. The outlined differences make each suitable for distinct scenarios. By understanding these distinctions and utilizing each component appropriately, teams can create more efficient, secure, and flexible applications that cater to the specific screen requirements of each OutSystems project.

Post Comment