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
zubair shareef mohammadzubair shareef mohammad 

If I have to fetch 1000 records through Soql but I have to reduce the execution time, how it is possible ?

If I have to fetch 1000 records through Soql but I have to reduce the execution time, how it is possible ?
karthikeyan perumalkarthikeyan perumal
Hello

always use lilmit in your query if the object contains more records, when you are limiting some amount of records.
use  Where condition area that may gives you better results. and dot not use contains or includus its perform a search based on Like operator in SQL. 
try to excute a Query in Workbench  and developer console as well.

There are several things you need to consider here:
How many records are you getting back?
How long does the same query take in the developer console?
What is the selectivity of the SOQL query?
These points can direct you towards the problem. For example, if the same query is fast in the developer console and is returning a large number of records then the problem is most likely not using compression in the SOAP response. See SOAP Compression
If the selectivity of the query is poor then you should look at getting indexes added or reworking the query. See Make SOQL query selective.
Incidentally, the Salesforce StackExchange is a great place to ask Salesforce specific questions. 

Hope it will help you. 

Thanks 
karthik
 
Jha dilipJha dilip
Hi 

you can check your query in query planner in developer console there you can find how much record is returned and it can help you to understand indexing needs to be done or not for increasing query run time.

Regards