0

Good everyone,

I am creating a visual force page. Inside on it, is an<apex:selectRadio> wherein when I select one of the radio, it will get data from controller and rerender some outputpanel of my page. I am using <apex:actionSupport> to do it. I am using 2 way to do the query. First, I've tried to query data from the database every time I select the radio button and the second way is that I query all value from the database that I needed and I store it in Map, and everytime I select a radio button I will get some data from the map. I am confuse what is the best thing to do to make the processing faster. In your own idea, what is faster in the 2 method i've tried. Please give me your idea about this.

Thank you.

1 Answer 1

2

Retrieving from a map will be faster than running a soql query, but may run into viewstate issues if the number of records you are storing in the map is very large. So, if your number of records retrieved from soql is going to increase over the lifespan of the application and/or you expect there to be a lot of records, you may want to do a smaller soql query each time rather than store them to prevent reaching the viewstate limit after your application has been working for a little while. You can also hybridize it by retrieving a map which points to the IDs of the records you'll need to send back to the page, and then run a SOQL query against those IDs.

With all that said, if performance is an issue on the page, you may be able to improve it by doing one of two things:

  1. Add <apex:actionSupport> elements around the data you need to send back. This limits the size of the data sent back to the controller on postback actions and reduces the area that gets rerendered, which might make a difference.

  2. If you don't mind writing some javascript, you may want to look into Javascript Remoting, which will use AJAX calls rather than post back. Since this is asynchronous, the page does not rerender after the call returns and instead it is up to you to update it through the javascript callback.

You must log in to answer this question.

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