1

I appreciate there are some similar existing questions but I am after approaches on how to debug a slow Visualforce page, as in find what specifically could be causing a slow load/action. I don't have a specific example to share but I would like to have a better understanding on how to test if a page I am working on is as efficient as it could be or to highlight future/potential issues.

To clarify I understand the developer console offers view state but not how to use it. Is something like firebug also an option? Any step by step instructions, or key things to look out for, to either of these approaches, or any different approaches, would be greatly appreciated.

I've learnt to code in apex as an extension of being a Salesforce Admin so understanding the impact on browsers is an area I am weak on.

1 Answer 1

2

Perhaps someone will write a less "link only" answer, but these (bulky) documents are central to the answer:

Some personal experience:

Sometimes a lot of emphasis is given to query optimization (which should be done) but the rendering part of the work - where the apex:xxxx tags execute - can also be very time consuming. Showing less content in your pages is one choice to address that but you'll have to convince your users of that sort of change. The apex:xxxx also contribute view state, and using raw HTML instead is sometimes worthwhile.

Because controller fields default to being included in the view state, you will probably find that making a lot more fields transient will help performance.

I spent a couple of days optimising two big pages that hadn't been optimised for a couple of years and it wasn't too hard to halve the page load time just based on the feedback that the Developer Console provided.

PS

To expand on the point about transient fields, this lazy loading approach is sometimes used in controllers:

public Contact[] contacts {
    get {
        if (contacts == null) {
            contacts = [select FirstName, LastName, Birthdate, ... from Contact where ...];
        }
        return contacts;
    }
    private set;
}

It has the advantage that the query is done once the first time the field is referenced and further references (in other methods in the controller class and finally when the page is rendered) just use the cached data. But it has the disadvantage that all the data is included in the view state meaning it is sent to the client (as part of a large hidden field) and is sent back to the server and turned back into the collection when e.g. a form is submitted. That can be time consuming when the collection has many rows so it can be sometimes be worth changing to this transient pattern instead.

2
  • 1
    Thanks Keith that's a great help to getting me started. Could you clarify what you meant by making more fields transient?
    – Girbot
    Dec 3, 2014 at 15:13
  • 1
    @Girbot See the PS I just added. Always worth measuring first before assuming something is a problem i.e. change the code that matters not 80+% of code that doesn't matter.
    – Keith C
    Dec 3, 2014 at 15:57

You must log in to answer this question.

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