function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Harpreet On CloudHarpreet On Cloud 

Are Formula fields better for performance?

As far as the performance is concerned, it is better to reduve no. of joins in the query by doing a de-normalization. How can we do a de-normalization?

 

Is using a formula of Account field in Contact a sense of de-normalization so that we do not use Account object while writing a query on the Contact object? Are formula fields stored as a data internally and updated as and when the source data gets updated? If no, are roll-up summary fields also calculated at runtime rather than storing them internally?

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Rollup summary fields are stored internally and updated (asynchronously?) when related records are affected. Formula fields are never stored in the database at all, but instead are calculated in real time when a query, page, or report requests them. For this reason, it is considered poor practice to filter on a formula field because it causes a full table scan if there are no indexed filters (actually WORSE than a full table scan, because each row has to be calculated).

All Answers

Starz26Starz26

Formula fields are updated every time they are "seen"

 

i do not believe they are stored as data per se but I could be wrong, rather the value is calculated every time it is needed or seen by something

sfdcfoxsfdcfox

Rollup summary fields are stored internally and updated (asynchronously?) when related records are affected. Formula fields are never stored in the database at all, but instead are calculated in real time when a query, page, or report requests them. For this reason, it is considered poor practice to filter on a formula field because it causes a full table scan if there are no indexed filters (actually WORSE than a full table scan, because each row has to be calculated).

This was selected as the best answer
Bernadett Dömötör 5Bernadett Dömötör 5
This article is bit old but just for the record, I found this in the documentation regarding formulas:
Formula fields run with workflows, so they don't slow down reports at run time.
Source: https://help.salesforce.com/articleView?id=improving_report_performance.htm&type=5