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
J&AJ&A 

Initial VF page load time is either too long or it times out

Hi all,

 

I'm having a problem with a visualforce page that I've developed. The initial load either times out or it takes over 30 secs. After the page has loaded though, it takes less than a sec to reload the same page. My first thought was to check the view state size of the page, which is about 20K. I can optimize the view state size of the page later if needed, but at 20K, I didn't think this could be the culprit. 

 

I'd post my VF page/Apex controller, but they are very long so I'll try to walk through the code:

Controller

- Within its constructor, I perform 5 total queries: one SOQL to get some custom fields from the current user, one SOQL to get the profile name of the current user, one SOSL to get all the users within a certain criteria (I use the LIKE operator in it), one SOQL to search events and the last one to get tasks.

- I really don't like the fact that I'm running 5 queries within the constructor. But I wasn't sure how I could refractor them to help the load issue.

 

VF page

- There are three main components: one block that allows users to use a custom search, one block that shows their events and the last block that shows their tasks.

- One thing that I do within the page is to use the data from the controller extensively. For example:

<apex:column width="20%" styleClass="custTableClass">
<apex:facet name="header">
        <apex:outputText value="Description"/>
        </apex:facet>
        <div id="desc{!e.evt.Id}_{!e.evt.ActivityDate}">
                <apex:outputField value="{!e.evt.Description}"/>
        </div></apex:column>

 I use jquery to apply row coloring and such on a pageBlockTable, so I wrap apex components within a div tag so that I pass the event's id and date as part of the id attribute. I use this technique extensively within my page, so I didn't know if this could have any impact on page load.

 

Let me know if I need to provide any further info. And sorry for the long post.

 

Thanks!

 

Best Answer chosen by Admin (Salesforce Developers) 
J&AJ&A

Thanks for the suggestions. I was able to identify and to fix the issue this morning. From what I can tell, the long load time was due to the usage of the LIKE operator within my SOSL. I ended up refractoring that portion of the controller by removing the LIKE operator from my SOSL and by adding more selective filters.

 

Additionally, I ended up reducing the view state of the page to about 7KB from the original 20 KB.

 

Thanks again.

All Answers

MelliottMelliott

Are you using any rerender logic on the page via data.  I've run into that with load times and it drove me batty.  I had to break it into seperate pages.  Just a thought. 

grigri9grigri9

Run the force.com Console and look at the Timeline view. This gives a breakdown of exactly where you are spending your time when the page loads. Once you know that you can figure out what you need to optimize.

 

I would also highly recommend this webinar. It gives a really good overview of the most common vf performance issues.

J&AJ&A

Thanks for the suggestions. I was able to identify and to fix the issue this morning. From what I can tell, the long load time was due to the usage of the LIKE operator within my SOSL. I ended up refractoring that portion of the controller by removing the LIKE operator from my SOSL and by adding more selective filters.

 

Additionally, I ended up reducing the view state of the page to about 7KB from the original 20 KB.

 

Thanks again.

This was selected as the best answer