+ Start a Discussion

how to optimise soql query

There is a simple SOQL query ‘Select Id, Name from Opportunity’ which fetches millions of records without any selection criterion. How do we optimize the performance of this simple query without using any selection criterion ?
SandhyaSandhya (Salesforce Developers) 

The performance of a SOQL will depend on the presence of a selective filter. If a SOQL query contains at least 1 selective filter, the query is said to be selective. If the SOQL query doesn't contain a selective filter, the query is said to be un-selective and will require a full table scan.Consider an indexed filter 

Please refer below link which explains about this.

Hope this helps you!

Please mark it as Best Answer if my reply was helpful. It will make it available for other as the proper solution.
Thanks and Regards