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

Retrieve count of a list instead of retrieve then count

4

Hi,

 

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.

 

 

Regards,

asked
5 answers

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

Created

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.

Created

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.

Created

Thanks for the valuable comment Tim.

Created

Actually, Mendix does that for you. Check out the documentation about this: https://docs.mendix.com/howto/logic-business-rules/optimizing-microflow-aggregates

Created