Aggregates & Advanced Queries


Food for the though ....

It's well known that when the "Max. Records" is not specified in an Aggregate or Advanced Query, the Agile Platform will determine internally the value of the "Max. Records", avoiding loading the full table's contents into the server.
Having this in mind, and from the server's point of view, what are the impacts of using the "Count" value of an Aggregate or Advanced Query? Will the platform perform an additional query, returning the total number of lines? If so, does this only happen when the "Count" value is used in the code?

Kind regards,
José Martins
Hi José,

Yes, calling .Count will perform an additional query to run COUNT(*) which is far more efficient than use Length for example, that retreives the records, push them into memory and then count the number of records. The only times in which .Length is a good choice, is when you already have get all the records anyways to be displayed on screen (not using Start Index and Record Count).

?Best regards,


Length is a list operation, and returns the length of the actually fetched list, which will be page size + 1 if you use paging. So it's not inefficient, but it doesn't return useful results.
That's correct Kilian, thanks. Actually I mean that if you wish to count all records of a table, in order to use Length is inefficient because you need to execute a query without start index and record count (from pagination purposes) and retrieve all the records, so the list operation result would be equal to the Count.
Ok, then we both agree :).