I have a set of results that I want to find some average values, divided
into group_1, _2, and _3. I have two options.
-
Find all and then loop through all and in each loop calculate how
many there are and the summery for each and get the average for each.
-
Use the calculation method Model.average() 3 times.
Which one is fastest? And what happens when there are more groups?
You should try both and report back.
Regards,
Craig
Craig D. wrote:
You should try both and report back.
Regards,
Craig
I don’t have so many post in my db and I thought someone might have the
answer. I’ll will add some and try it.
Frederick C. wrote:
On Feb 21, 8:57�pm, P�l Bergstr�m [email protected]
wrote:
I would expect Model.average to be much faster - aggregating lots of
data is something databases are good at, and something for which
instantiating 10s of thousands of active record objects is
unnecessary.
Fred
Thanks. That was what I suspected.
On Feb 21, 8:57 pm, Pål Bergström [email protected]
wrote:
Craig D. wrote:
You should try both and report back.
Regards,
Craig
I don’t have so many post in my db and I thought someone might have the
answer. I’ll will add some and try it.
I would expect Model.average to be much faster - aggregating lots of
data is something databases are good at, and something for which
instantiating 10s of thousands of active record objects is
unnecessary.
Fred