Skip to main content

Query Plan

SOQL Query Plan is a Salesforce feature that helps developers and administrators understand how their SOQL queries are executed by the Salesforce database engine. It provides insights into the performance of queries and helps identify potential bottlenecks or inefficiencies.

Brobench provides a way to analyze the query plan of SOQL queries and visualize the Salesforce response.

There are two ways to view the Query Plan of a SOQL query

  1. While you are in the Query Editor, select the Query you want to analyze and click on the Execute Other button and select the View Query Plan option.

  1. Once you have executed a query, you can view the Query Plan of that query by clicking on the More Actions menu in the Query Datagrid and select the View Query Plan option.

Once you select the View Query Plan option, Brobench will display the Query Plan dialog with plan details as shown below.

Understanding the Query Plan

Here are the various fields and what they mean from here.

Cardinality
Fields
Leading Operation Type
Cost
sObject Cardinality
sObject Type

The estimated number of records that the leading operation type would return. For example, the number of records returned if using an index table.

 

The indexed field(s) used by the Query Optimizer. If the leading operation type is Index, the fields value is Index. Otherwise, the fields value is null.

The primary operation type that Salesforce will use to optimize the query.
  • Index - The query will use an index on the queried object.
  • Sharing - The query will use an index based on the sharing rules associated with the user who is executing the query. If there are sharing rules that limit which records that user can access, Salesforce can use those rules to optimize the query.
  • TableScan - The query will scan all records for the queried object.
  • Other - The query will use optimizations internal to Salesforce.

The cost of the query compared to the Force.com Query Optimizer’s selectivity threshold. Values above 1 mean that the query won’t be selective.

The approximate record count for the queried object.
The name of the queried.
 

Resources

Here are additional resources you may find helpful to understand and optimize your SOQL queries