Counting objects

1
For reporting purposes I need a retrieve function which only returns a count of the objects that match the selectioncriteria (expression). Now I first have to retrieve all matching objects in a list and then use a list aggregation to count the objects (leads to bad performance). Is there an easier/better way to do this?
asked
4 answers
5

If count is the only action you perform on the list, the query is optimized. You can trace the connectionbus to check which sql queries are generated, just to be sure.

answered
0

You can have a parent object in which you store the value of its amount of children. Whenever you add or remove associations, adjust the count.

Edit: I want to add that I think your best best is to somehow capture this aggregate data in objects. Also, is the count a real-time number or could your run a Scheduled Event to perform these larger calculations periodically throughout the day?

answered
0

In this case both solutions offered by Jason are not an option because the count is dependent on selection criteria entered by the end-user (like date from/until) and thus dynamic.

answered
0

Hi Rene,

I guess you can try in this way, create a domain entity like ReportingEntity with attributes like time stamp and count number. Hence create this entity based on the selection criteria from user , save it and display it. Now it will be totally your choice whether you want to update the existing row or create a new row each and every time.

hope this suits your requirement :).

answered