You need to sign in to do that
Don't have an account?
SFDC coder
How to improve a list's performance?
hi all,
i have a functionality wherein the pageblock table data is sorted when an appropriate column header is clicked.
Even though this functionality seems to be working fine,
it takes a lot of time to display the result on the VF page
Can anyone help me to make the records display faster on VF page?
below is my method i.e invoked whenever a column header is clicked
i have a functionality wherein the pageblock table data is sorted when an appropriate column header is clicked.
Even though this functionality seems to be working fine,
it takes a lot of time to display the result on the VF page
Can anyone help me to make the records display faster on VF page?
below is my method i.e invoked whenever a column header is clicked
public PageReference doSorting() { wrapperLst.clear(); sortOrder= sortOrder.equals('asc') ? 'desc' : 'asc'; System.debug('***** sort order is'+sortOrder); List<Product__c> prodlst=runQuery(); if(prodlst.isEmpty()==false) { for(Product__c pnew2: prodlst) { OrderWrapper ow2=new OrderWrapper(); ow2.prodItem=pnew2; ow2.oliItem=new Order_Line_Item__c(); ow2.isChecked=false; wrapperLst.add(ow2); } } return null; } public List<Product__c> runQuery() { sortedProds.clear(); sortedProds=Database.Query('select id,name,Product_Brand__c,Product_Category__c from Product__c Order by '+sortParam+' '+sortOrder); return sortedProds; }
Looks like the real bottleneck is your query at line 24. You have no filters on your query so it's going to do a full table scan and return all results of your Product__c object. If the query is unbearably slow, you'll want to look into indexing and other forms of query optimization. Perhaps this will help: http://help.salesforce.com/help/pdfs/en/salesforce_query_search_optimization_developer_cheatsheet.pdf
Something like the jQuery table sorter should be able to help http://tablesorter.com/docs/.