I stumbled upon an issue in the article search page today and not able to reason it. Below is the sample controller for querying knowledgearticle which SFDC has provided in the knowledge aricle guide. If you look at the constructor there is a query that fetches all the published articles based on the language, so my question is would the page work properly if my org has more than 50k published articles? i was puzzled because this code is straight from the developer guide and i am hoping that SFDC wouldn't give sample codes which are not bulk efficient. So Incase any of you had faced the issue before pls let me know on how you would tweak the code to support more than 50k records?
public with sharing class vfListPaginationController {
//Page Size
private Static Final Integer PAGE_NUMBER = 10;
public vfListPaginationController() {
// What happens below when the article records > 50k ???
String qryString = 'SELECT Id, title, UrlName, LastPublishedDate,LastModifiedById FROM
KnowledgeArticleVersion WHERE (PublishStatus = \'online\' and Language = \'en_US\')';
List<KnowledgeArticleVersion> articleList= Database.query(qryString);
maxSize = articleList.size() ;
}
//Keeps track of current page & max size of article list
Integer currentPage = 1;
Integer maxSize = 1;
// Returns whether we need to see previous button or not
public boolean getPrevRequired() {
return currentPage > 1;
}
// Returns whether we need to see next button or not
public boolean getNextRequired() {
return currentPage * PAGE_NUMBER < maxSize;
}
//Returns current page number
public Decimal getCurrentPageNumber() {
return this.currentPage;
}
//action for next click
public PageReference next() {
if(maxSize > this.currentPage * PAGE_NUMBER) {
this.currentPage = this.currentPage + 1;
}
return null;
}
//action for previous click
public PageReference previous() {
if(this.currentPage > 1)
this.currentPage = this.currentPage - 1;
return null;
}
}