No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Get Feedback on Query Performance
Use the Query resource along with the explain parameter to get feedback on how Salesforce will execute your query. Salesforce analyzes each query to find the optimal approach to obtain the query results. Depending on the query and query filters, an index or internal optimization might get used. You use the explain parameter to return details on how Salesforce will optimize your query, without actually running the query. Based on the response, you can decide whether to fine-tune the performance of your query by making changes like adding filters to make the query more selective.
The response will contain one or more query execution plans that, sorted from most optimal to least optimal. The most optimal plan is the plan that’s used when the query is executed.
See the explain parameter in Query for more details on the fields returned when using explain. See “More Efficient SOQL Queries” in the Apex Code Developer’s Guide for more information on making your queries more selective.
Example
- Example usage for getting performance feedback on a query that uses Merchandise__c
1/services/data/v32.0/query/?explain= 2SELECT+Name+FROM+Merchandise__c+WHERE+CreatedDate+=+TODAY+AND+Price__c+>+10.0- Example response body for executing a performance feedback query
1{ 2 "plans" : [ { 3 "cardinality" : 1, 4 "fields" : [ "CreatedDate" ], 5 "leadingOperationType" : "Index", 6 "relativeCost" : 0.0, 7 "sobjectCardinality" : 3, 8 "sobjectType" : "Merchandise__c" 9 }, { 10 "cardinality" : 1, 11 "fields" : [ ], 12 "leadingOperationType" : "TableScan", 13 "relativeCost" : 0.65, 14 "sobjectCardinality" : 3, 15 "sobjectType" : "Merchandise__c" 16 } ] 17}This response indicates that Salesforce found two possible execution plans for this query. The first plan uses the CreatedDate index field to improve the performance of this query. The second plan scans all records without using an index. The first plan will be used if the query is actually executed.