0

I'm trying to understand the performance difference or query execution time between direct SOQL query and relationship query. For example, I need data from Account and User object. sap_id__c is the common field in both account and user objects and will have the same value for a user for records on both the objects.

Relationship query:

select id, contact.AccountId from user where sap_id__c = '1234'

Two individual straight queries:

select id from user where sap_id__c = '1234'

select id from account where sap_id__c = '1234'

1 Answer 1

1

The relationship query is more efficient in every way. You only use one query, one query row, and it's just less code overall. When possible, you should definitely leverage relationship queries to reduce governor limit usage whenever possible.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .