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
taralextaralex 

First API query() request takes too long

I'm using Salesforce.com Webservices API in my .NET application and I noticed that when I send my first query after log in, it takes an enormous amount of time. About one minute passes before I receive the reply. And sometimes it even times out.

However, when I do exactly the same query the second time around, it comes back in under 1 second...

Is there anything I could do work around this?

Mohith Kumar ShrivastavaMohith Kumar Shrivastava

There are few suggestions that i could give 

 

1)Use where clause in query to optimize the query

 

2)If there are huge records limit the query and provide only recent items to user and give a search box for user to search data

 

3)You can request custom indexing from salesforce if data is huge in your org

taralextaralex

Well in my case I query the Account object, of which there are about 4 million records, but the where clause is constructed to return just one record. The first time after logging in it takes forever whereas the second and all subsequent queries are pretty fast.