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
Simon Coles 2Simon Coles 2 

When logging into SFDC for the first time each day, the initial SOQL query takes around 30-40 seconds. Any subsequent searches take around 2-3 seconds.

If any user performs the initial search, all searches for subsequent users are 2-3 seconds. 

Is there anyway of preventing this?  Does SFDC need to spin up the first time and can we cache the data set? 
VineetKumarVineetKumar
Is it through a VF page?
Simon Coles 2Simon Coles 2
Yes, it's through a VF page.  We have around 1.5 million records in the system and I've indexed (external id) the most used fields.

These are the steps to replicate If I don't use the system for 24 hours.
  • Log in to SFDC
  • Navigate to my VF page (which loads the initial records set quickly 10,000 records)
  • I then filter the results (first one takes 30-40 seconds) then subsequent filters take 2-3 seconds.
This happens only for the very first user logging in - once someone has logged in and performed a filter ALL users responses are 2-3 seconds.

 
VineetKumarVineetKumar
This is due to a concept called "Database Caching".
Saleforce is also storing data using RDBMS, to avoid extra overhead of fetching the data always salesforce database keeps the data in it's cache for some time, this improves scalability by distributing query workload from backend to multiple cheap front-end systems. Benefit incude improved data access speeds brought about by locality of data and smoothing out load peaks by avoiding round-trips between middle-tier and data-tier.

More details can be found that the below FAQ by Salesforce :
https://help.salesforce.com/apex/HTViewSolution?id=000181277&