5

I am trying to decrease the page load times on my two visualforce pages. Both of them are pretty simple queries, I am not sure why it is taking a long time to load each of the pages. The main one I am concerned about is this one:

The controller:

public class EZCampaignEditorExt{

    public EZCampaignEditorExt() {
    }


  //  String Qmain = 'Select Id, Topic_Name__c, Name, Status, Expert_Cost__c, Moderator__c, Expert__c, GRI_Event_Type__c, Call_debit__c, Call_date__c from Campaign';
    public list<Campaign> PrevWeek = [Select Id, Topic_Name__c, Status, Expert_Cost__c, Moderator__c, Expert__c, GRI_Event_Type__c, Call_date__c from Campaign where Call_date__c = Last_Week Order by Call_date__c ASC]; 
    public list<Campaign> ThisWeek =[Select Id, Topic_Name__c, Status, Expert_Cost__c, Moderator__c, Expert__c, GRI_Event_Type__c,  Call_date__c from Campaign where Call_date__c = This_Week Order by Call_date__c ASC];
    public list<Campaign> NextWeek =[Select Id, Topic_Name__c, Status, Expert_Cost__c, Moderator__c, Expert__c, GRI_Event_Type__c, Call_date__c from Campaign where Call_date__c = Next_Week Order by Call_date__c ASC];

    public PageReference save(){
        update PrevWeek;
        update ThisWeek;
        update NextWeek;
        PageReference pageRef = ApexPages.currentPage();
        pageRef.setRedirect(true);
        return pageRef;
    }



    public list<Campaign> getPrevWeek(){
        Return PrevWeek;
    }


    public list<Campaign> getThisWeek(){
        Return ThisWeek;
    }

    public list<Campaign> getNextWeek(){
        Return NextWeek;
    }

}

Here is the VF page:

<apex:page Controller="EZCampaignEditorExt">
<apex:form >
<apex:commandButton value="Save" action="{!save}"/>
<apex:pageBlock mode="InLineEdit">
<apex:pageBlockSection columns="1" Collapsible="True" Title="Previous Week">


<apex:pageBlockTable value="{!PrevWeek}" var="Pweek">
<apex:column headerValue="Call Date">
<apex:outputText value="{0,date,E '-' MM'/'dd'/'yyyy}">
    <apex:param value="{!Pweek.Call_Date__c}" /> 
</apex:outputText>
</apex:column>

<apex:column headerValue="Name">
<apex:outputlink value="/{!Pweek.id}" >{!Pweek.Topic_Name__c}</apex:outputlink>
</apex:column>

<apex:column headerValue="Expert">
<apex:outputfield value="{!Pweek.Expert__c}" />
</apex:column>




<apex:column headerValue="Status">
<apex:outputfield value="{!Pweek.Status}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Expert Cost">
<apex:outputfield value="{!Pweek.Expert_Cost__c}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Moderator">
<apex:outputfield value="{!Pweek.Moderator__c}" ></apex:outputfield>
</apex:column>

<apex:column headerValue="Event Type">
<apex:outputfield value="{!Pweek.GRI_Event_Type__c}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Registration">
<apex:outputLink value="/apex/GRIRegistration?id={!Pweek.id}">Registration</apex:outputLink>
</apex:column>

<apex:column headerValue="Attendance">
<apex:outputLink value="/apex/GRIAttendance?id={!Pweek.id}">Attendance</apex:outputLink>
</apex:column>


</apex:pageBlockTable>
</apex:pageBlockSection>

<apex:pageBlockSection columns="1" collapsible="True" Title="This Week">

<apex:pageBlockTable value="{!ThisWeek}" var="Tweek">
<apex:column headerValue="Call Date">
<apex:outputText value="{0,date,E '-' MM'/'dd'/'yyyy}">
    <apex:param value="{!Tweek.Call_Date__c}" /> 
</apex:outputText>
</apex:column>

<apex:column headerValue="Name">
<apex:outputlink value="/{!Tweek.id}" >{!Tweek.Topic_Name__c}</apex:outputlink>
</apex:column>

<apex:column headerValue="Expert">
<apex:outputfield value="{!Tweek.Expert__c}" />
</apex:column>



<apex:column headerValue="Status">
<apex:outputfield value="{!Tweek.Status}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Expert Cost">
<apex:outputfield value="{!Tweek.Expert_Cost__c}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Moderator">
<apex:outputfield value="{!Tweek.Moderator__c}" ></apex:outputfield>
</apex:column>

<apex:column headerValue="Event Type">
<apex:outputfield value="{!Tweek.GRI_Event_Type__c}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Registration">
<apex:outputLink value="/apex/GRIRegistration?id={!Tweek.id}">Registration</apex:outputLink>
</apex:column>

<apex:column headerValue="Attendance">
<apex:outputLink value="/apex/GRIAttendance?id={!Tweek.id}">Attendance</apex:outputLink>
</apex:column>

</apex:pageBlockTable>
</apex:pageBlockSection>

<apex:pageBlockSection columns="1" collapsible="True" Title="Next Week">

<apex:pageBlockTable value="{!NextWeek}" var="Nweek">
<apex:column headerValue="Call Date">
<apex:outputText value="{0,date,E '-' MM'/'dd'/'yyyy}">
    <apex:param value="{!Nweek.Call_Date__c}" /> 
</apex:outputText>
</apex:column>

<apex:column headerValue="Name">
<apex:outputlink value="/{!Nweek.id}" >{!Nweek.Topic_Name__c}</apex:outputlink>
</apex:column>

<apex:column headerValue="Expert">
<apex:outputfield value="{!Nweek.Expert__c}" />
</apex:column>

<apex:column headerValue="Status">
<apex:outputfield value="{!Nweek.Status}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Expert Cost">
<apex:outputfield value="{!Nweek.Expert_Cost__c}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Moderator">
<apex:outputfield value="{!Nweek.Moderator__c}" ></apex:outputfield>
</apex:column>

<apex:column headerValue="Event Type">
<apex:outputfield value="{!Nweek.GRI_Event_Type__c}"></apex:outputfield>
</apex:column>

<apex:column headerValue="Registration">
<apex:outputLink value="/apex/GRIRegistration?id={!Nweek.id}">Registration</apex:outputLink>
</apex:column>

<apex:column headerValue="Attendance">
<apex:outputLink value="/apex/GRIAttendance?id={!Nweek.id}">Attendance</apex:outputLink>
</apex:column>

</apex:pageBlockTable>

</apex:pageBlockSection>


</apex:pageBlock>
<apex:commandButton action="{!save}" value="Save"/>
</apex:form>

</apex:page>

Should I investigate maybe using AJAX? All suggestions welcome. Thanks in advanced.

4
  • Have you tried running the SOQL queries in another tool such as Workbench or Developer Console to see how ling they run? Commented Nov 14, 2013 at 20:11
  • What do you mean with taking a long time, how long? Commented Nov 14, 2013 at 20:12
  • @mast0r - about 19 seconds to load the page. WAY to long. The queries are taking ~6.5 seconds each. Do you suggest a way to divide it up? Maybe Query to a list and load them into a map then load each ones that match date."this_week", date."last_week" and date."next_week" into their respective lists?
    – AlphaBravo
    Commented Nov 14, 2013 at 21:02
  • What about just querying less data ...? Is some sort of pagination or separated screens no option ? Commented Nov 15, 2013 at 5:19

1 Answer 1

6

While it is probably the case that the problem is simply that you are presenting a large number of fields in a single page - something that Visualforce is not fast at doing - it is worth checking that there isn’t just one very slow operation causing the problem.

To that end, I recommend using the Developer Console; open it then open one of your pages. Double click on the resulting log entry to open it, then use Debug -> View Log Panels and select Execution Overview. Then select the Executed Units tab. This presents an excellent consolidation of log entries (e.g. sum of time, time per call, number of calls) that should allow you to see where the time is going and might highlight a bottleneck.

Assuming there isn't a bottleneck, if you really need to present all the fields in a single page, see Advice on speeding up Visualforce pages? for some approaches that might help.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .