2

When querying records by lookup object's indexed field, the Query Plan shows something like this:

Now, the docs say that:

The Query Plan tool will show a list of available plans that our Query Optimizer can utilize for the query provided and will be arranged by cost ascending. (...) The plan with the lowest cost is the plan that is used for driving the query execution.

Does it mean that always only the single row with the lowest cost will be used, or is it more like 'the plan with the lowest cost for each sObject is used'? In other words, will the cost here be 0, or 0 (lowest Account cost) + 2.83 (lowest Contact cost)?

I suppose the former (well, not really 0, seems like a bug), as there's no need to perform full scan when Contacts are indexed by AccountId an thus it should be more like O(log(n)) complexity.

3

No, it'll be literally just the External ID field. The system will leverage the index of lookup fields to find only the contacts that match the account with the External Id. There won't be a full table scan on the contact records, since they'll be filtered by "Account Id", effectively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.