Scenario
Let's say I have two custom obejcts - Student
and Class
. The Class
object is connected with object Student through lookup relationship. The Class
object also has a formula field (Student_UniqueCode__c
):
Student__r.uniqueCode__c.
Now while doing SOQL, which one I should use, the formula field or the relationship to get better performance?
Query 1
Select Student_UniqueCode__c from Student__c
or
Select Student__r.uniqueCode__c from Student__c
Query 2
Select <..> from Student__c where Student_UniqueCode__c like ...
or
Select <..> from Student__c where Student__r.uniqueCode__c like ...