function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vijay NagarathinamVijay Nagarathinam 

query plan

Hi All,

I am trying to find the query cost using query plan in the console. It showing two values which one I need to consider the query cost,

User-added image
Khan AnasKhan Anas (Salesforce Developers) 
Hi Vijay,

Greetings to you!

TableScan - The query will scan all records for the queried object.
Other - The query will use optimizations internal to Salesforce.

Other is one of the possible optimizations that could be applied if the circumstances require it. Although the lowest cost should always be used.

According to this knowledge article:

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.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
SandhyaSandhya (Salesforce Developers) 

The plan with the lowest cost will be the plan used.Refer below help article on this.
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards