Posts

Showing posts with the label queryCount

Salesforce Fact #933 | Query row count for parent to child soql

The query rows count is a bit different in case of SOQL with parent to child subquery. For example, if there are 5 accounts each having 2 contacts in the org, then the below query would return 15 query rows while calling Limits.getQueryRows(): [SELECT Id, (SELECT Id FROM Contacts) FROM Account] i.e. total number of accounts + total number of contacts with related accounts Reference:  https://salesforce.stackexchange.com/questions/184131/what-is-the-limit-for-subquery-in-soql

Salesforce Fact #854 | recalculateFormulas() count towards SOQL query count

Image
We have the recalculateFormulas() function of Formula class which can evaluate the formula without saving the sobject record and this is super helpful in test classes. An interesting thing is, when the sobject record contains all the fields which are needed for the formula evaluation, then Formula.recalculateFormulas() does not count towards the total SOQL query count. But, if the sobject record does not have any of the field which is needed for the formula evaluation, the recalculateFormulas() call is counted as 1 SOQL query. In this example, we have two number fields, Test_Runs and ODI_Runs and a formula field, Total_Runs which is the sum of ODI and Test runs. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_Formula.htm#apex_System_Formula_recalculateFormulas Attached are the screenshots.