3

During my work I found this query on a table with around 181k records and dozen of fields. Putting the query on the query planner I found a strange result as you can see:

Query Plan 1

The query is as follows:

Select C****__c,Field_B 
    from List_of_values__c 
    where R**** =: var1 and C****__c =: var2 and Attrib_36__c = true;

Both R**** and C****__c have index.

The funny things is that if we remove either one of these the cost is good and as you can see this is the result:

Query Plan 2

Why does the Other cost pop up?

1
  • 2
    If R*** is RecordTypeId, there's not much point in obfuscating it...Also it doesn't really matter what shows up on your query plan outside of the most efficient plan, because that's the one which will be used.
    – Adrian Larson
    Mar 14 '17 at 14:43
5

From this KNOWLEDGE ARTICLE:

Other - The query will use optimizations internal to Salesforce.

And I believe it appears because it is one of the possible optimizations that could be applied if the circumstances require it. Although the lowest cost should always be used.

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. Each Plan will contain information on Cardinality, Operation Type, Cost, sObject Type, and more. Each plan has a “Leading Operation Type”, for example, Field Index or Full Table Scan. The plan with the lowest cost is the plan that is used for driving the query execution.

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.