When using OutSystems, SQLs help address complex data requirements. We often consider optimisation by retrieving only the needed data, also known as “lazy loading”. I’ve often seen a pattern where two separate queries have been made to achieve this.
The first query is to retrieve the paged data, and the second is to get the total count. This setup means two things – more processing time is needed at the data source, and you now have two elements to maintain, which means when you need to modify the query, you need to do it on both SQLs. Using the following syntax, please see the example below, you can get the total count of the rows beyond the max records.