2

I am creating a dashboard, and for example a Formula field will identify if the record has issues. I know that Formula fields are not indexed in SOQL. Can anybody tell what's the best approach in this case. The main issue is the loading time, because the query will return a large amount of records count().

I will appreciate any advises

0

I would change the formula field to be a regular field that is updated by a trigger, with the calculation done in the trigger (or trigger helper).

You lose some of the ease of configurability here, but it sounds like performance is the overriding concern which may mean taking the less "clean" approach for the sake of your reports actually working.

| improve this answer | |
  • 2
    the downside to using a trigger is that there needs to be a trigger on anything that was originally referenced in the formula (if it references multiple relationships). this is because formulas are evaluated at query time where as triggers at event (before/after insert/update/delete/undelete). – Andrew Monshizadeh Jul 9 '14 at 21:03
5

It used to be the case that formula fields were not indexable, but that's no longer the case, as long as the formula field is deterministic (i.e. it's value doesn't change outside of database events, the most common example being any formula using NOW()).

If you're running into performance issues with a report or query using that formula field, contact support and ask that they enable an index for it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.