Microflow Database

0
Which is the results in an optimized retrieve from the database? Retrieve objects via association followed by a Count activity Retrieve objects via association followed by a Count activity and then by a Sum activity Retrieve objects from the database followed by a Sum activity Retrieve objects from the database followed by a Count activity and then by a Sum activity
asked
3 answers
1

Hello Kirtti Azad Sahoo

                                            All the retrieve object via association is to connect those two entity attributed. The things which you mentioned will perform as best case when the business model or Logic is satisfied.

For example if u count the total number of employee in a company that gives a single whole number. this will be the best case for  1st option and worst case where you use a follow up sum.

I hope it will be useful

answered
1

A retrieve followed by an aggregate activity results in one query being done. 

If you have the opportunity use a retrieve over association (unless you need specific results or your business logic demands a DB retrieve) and use an aggregate function like Count or Sum. 

If the required information isnt in memory anyway a retrieve over association will default to a DB retrieve. 

If you want to perform multiple aggregates it, in general, is a good idea to retrieve/aggregate/retrieve/aggregate. As a rule of thumb ofcourse and there are exceptions. 

answered
0

Hello, Kirtti Azad Sahoo

In the case of retrieving the object(s) via association, if the objects or their associations are changed and not committed, the data is not yet available in the database. By retrieving By association, the data that is not committed can be retrieved.

So, I think it would optimize the retrieval process if I retrieve the objects from the database and then go through a count activity before doing a sum activity.

answered