I have written a lengthy visualforce page for an account plan. After working almost all of the kinks out, I am now concerned with performance. Simply put, the page takes longer to load than I think it should (for what it's worth, I removed well over half the fields on the page and it still takes longer than any other page in our org to load).

I have a standard controller defined on the account plan object, and a controller extension which handles pretty much all transactions on the page. For some reason -- and I have found nothing online about this -- when loading the page (even when clicking preview from the dev. console) it produces two debug logs.

I have confirmed that only one of them (the first one) is executing the controller extension's constructor. I figured the other log was a result of the account plan's constructor being executed, so I removed it and put the extension as the controller -- still 2 debug logs. First log takes 488 units, the second takes 498 units. The only dialogue I see in the second log references apex page messages controller, so I removed the page messages section from my VF page but still see the log, however it is shortened.

First Log

Second Log

Query: enter image description here

Code causing the issue: enter image description here

  • 3
    We'd have to see the logs (not all of it, just about the first 20 or so lines from each log). This would help us figure out the mystery. Odds are, it's some action that runs when the page loads, like an actionFunction, etc, but we have no way of knowing without seeing the logs.
    – sfdcfox
    Jul 11, 2017 at 16:47
  • Is it possible it is due to the form tags on the page? If so, is there anything I could do about that?
    – caseyjg
    Jul 11, 2017 at 18:33
  • Also, did you turn on profiling on the logs to see where time is being spent? Just another additional data point. Also, make sure you have development mode turned OFF in your user record. It will add to the page loading time and regular users will not see it anyway.
    – Eric
    Jul 11, 2017 at 21:24

3 Answers 3


The second log you posted shows a pair of entries for VF_DESERIA....


That suggests something has POSTed back the the controller immediately after the page loaded and sent back the corresponding viewstate.

It's difficult to tell exactly what is going on without access the full debug logs and ideally the corresponding Visualforce pages. Check your client side JavaScript to see if there is something doing a callback.

  • You were right, and it was due to me clicking a button using javascript on a popup, on page load. I posted the piece of code in question. It rerenders after the command button gets clicked and calls an action function, which clears the "showPopUp" variable. However, after putting return false after my onclick as well as putting rerender="tstpopup" and rerender="", the page still reloads.
    – caseyjg
    Jul 12, 2017 at 13:50
  • The <apex:actionFunction> is going to either rerender the entire page or the components identified by the rerender attribute. I've seen other recommendations to append return false; after the method call, but there seems to be an equal number of reports that it doesn't work. Instead, try setting the rerender attribute to tstpopup. That should rerender just the popup and cause it to be hidden. Jul 12, 2017 at 21:31

Solved the issue. As Daniel said, it was due to my javascript doing a postback after page load. I solved this in the following way: I wrapped an output panel inside of another output panel with a simple message -- 'please wait...'. Styling courtesy of https://developer.salesforce.com/forums/?id=906F000000097X9IAI. Then, at the end of my document.ready() function, instead of clicking a hidden button on that output panel to clear a value in my controller (which was the target of the output panel's rendered attribute), I simply find the outermost output panel using jquery and set the style.display attribute equal to 'none'. The result is the popup disappearing after the page is fully loaded.


Does the constructor run queries on tables with large datasets? (Get me all the sales orders for this account...) Usually a long running query will be the issue.

Make sure you're using aggregate queries if your just presenting summarized data. Otherwise you need to optimize your queries. There is a lot of documentation on this, I would start with: Working with Large Datasets or Cheat Sheet


You can run and check the queries' performance in the developer console.

  • Yes, I query over about 10 fieldsets with probably 10 fields each -- at least. But all of those fields are displayed on the page..
    – caseyjg
    Jul 11, 2017 at 19:18
  • Any chance you could post the code? Also a screenshot of the view state might be helpful. (developer.salesforce.com/page/…)
    – wellmstein
    Jul 11, 2017 at 19:23

You must log in to answer this question.

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