Trying to determine best scenarios for using AggregateResult

e.g. Versus using a for loop gathering totals with += or similar syntax.

  • 1
    I'm actually going to post something about this on my blog in the next 24 hours or so.
    – sfdcfox
    Commented Mar 7, 2016 at 17:32
  • Awesome! looking forward to it, didn't find much existing content out there on the topic
    – nickforce
    Commented Mar 7, 2016 at 17:44
  • @sfdcfox can you also include some best practices for using aggregateresults in batch apex? e.g. rowlimits and querylocator
    – nickforce
    Commented Mar 11, 2016 at 21:19

1 Answer 1


Use AggregateResult when possible. It always performs at least as well as manual loops. The more rows you need to process, the more you'll save in CPU time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .