+ Start a Discussion
Robin BarnwellRobin Barnwell 

Most efficient place to filter data?

I recently did PD2 and one of the questions I'm stuck on.  If you had a large data set that you wanted the user to be able to filter which is most efficent:
1. Rerun the SOQL each time with the new data filters
2. Hold the whole data set in memory and use Apex to filter
3. Use visualforce tags to filter - can't remember which ones

I went for hold in memory and use apex.  Can't find any documentation on best approach for performance.  any help?
Raj VakatiRaj Vakati
I am also thinking that is the best fit 

2. Hold the whole data set in memory and use Apex to filter

1. Rerun the SOQL each time with the new data filters -- Problem is you can't hold more than 10000 records 
3. Use visualforce tags to filter - can't remember which ones -- View state might be an issue 

 
Robin BarnwellRobin Barnwell
OK, got the answer - SOQL.  At the end of Chapter 4 of visualForce in practice it covers "advanced filtering - using standard set controllers inside custom controllers".  You use the <apex:actionsupport> tag within a <apex:selectlist> when the user changes the option the "onchange event" fires the call to a controller method to rerun the SOQL.  

Doesn't say anyting about it being the most efficent option, but its the best fit.