Retrieve count of a list instead of retrieve then count - Mendix Forum

Retrieve count of a list instead of retrieve then count




In the retrieve activity, why not to add an option retrieve only the count, instead of retrieving the full list with its data, and do another activity to count?

this will be very useful especially for designing complex dashboards, it will increase the performance in two ways:

  1. Executing the query on the DB level will be faster, since its “ SELECT COUNT(id) from...”
  2. DB Response will be much faster since its returning an integer, instead of a full list of data.




5 answers

I’d love to have an internal function that could be used on a list or association containing a list:


Yes, would love to keep the clutter in the flow minimized if we could lose the additional COUNT action after the retrieve and instead select it in the Retrieve action.


While Mendix optimizes the querie, I still think it could be a valuable addition, as it encourages users to do a “normal” retrieve only if they need to use the data after the count. Right now, too many developers still use the result of the retrieve further down the microflow, while in many cases the count alone suffices and the optimization of doing just the count is lost.


Thanks for the valuable comment Tim.


Actually, Mendix does that for you. Check out the documentation about this: