I have a few visualforce pages that, together, make up a custom dashboard. The first page or "shell" page is just a HTML form that lets you select a client services rep and an optional client type selector. Clicking submit calls an AJAX load call (via jquery) to inject the second page body contents - which is a VF page with a list of accounts and some embedded data (in sub-queries).
The very first time you load the page, it can take up to 20-30 seconds...after that it takes about 2-3 seconds. This is regardless of which client rep I select and the number of accounts or amount of embedded sub-query data.
None of the pages use an apex:form (to eliminate viewstate tax). The issue arises only sporadically and only the first time a person loads the page.
When I used the Dev Console it shows a huge block of time where the DB transaction holds the page for like 19 seconds.
I'm wondering if anyone has seen a case where there is some delay or deferred processing because of the way the page is being called and injected. I can't for the life of me figure out what would cause such a huge delay on a query - it contains a number of sub-queries but I have a third page (predicated on this page) that loads even more data with more conditions and is never a problem. Given that the third page works fine I'm wondering if its an authentication or caching issue...but if that was the case, why would the Timeline blame the DB call (unless it's mistakenly identifying the hold up)? Stumped.