In addition to the spanning relationship limit, there are some other important considerations when using formula fields. There are 3 more:
1. Character limit
Formula fields can have a maximum of 3,900 characters. This includes spaces, carriage returns, and comments.
You can easily solve this limit by reducing spaces, or by splitting the formula into sub-formulas.
2. Compile size
They can have a maximum compile size of 15,000 bytes. FYI, a field is compiled when it’s saved as a database query and executed using actual data at runtime.
This issue can be solved in various ways, including reducing the number of references to other fields, reducing the use of date operations, and replacing the formula with a flow.
3. Querying performance
Since formulas are not stored in the database, they are not indexed. FYI, indexing is a way of specifying which fields are key or unique fields. Indexing allows the database to locate specific rows much more quickly.
This means when using a formula in queries, a full scan is required to find records. This causes performance issues.
The takeaway
Formula fields are very useful, but they need to be used with caution.