Query Plan in Salesforce

The new Query Plan tool in the Developer Console can help speed up SOQL queries done over large volumes. Use the Query Plan tool to optimize and speed up queries done over large volumes.

To enable Query Plan, use the below link

http://www.infallibletechie.com/2015/07/how-to-enable-query-plan-in-salesforce.html

To use the tool, enter your query and click the Query Plan button in the Query Editor. The Query Plan window displays all query operations and the cost of each.

Cardinality
The estimated number of records that the leading operation type would return. For example, the number of records returned by an index.

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

LeadingOperationType
The primary operation type that Salesforce will use to optimize the query.
Index - The query will use an index on the query object.
Other - The query will use optimizations internal to Salesforce.
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 query object.

Notes
An array of one or more feedback notes. Each note contains:
description - A detailed description of an aspect of the optimization. This could include information on optimizations that could not be used, with details on why the optimization was not used.
fields - An array of one or more fields used for the optimization.
tableEnumOrId - The table name for the fields used for the optimization.
This response field is available in API version 33.0 and later.

RelativeCost
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.

sobjectCardinality
The approximate record count for the query object.

sobjectType
The name of the query object.

Sample Query Plan Execution:

1. Enter a Query and click "Query Plan".


2. Query Plan window opens and shows the result.


Cheers!!!

No comments:

Post a Comment