from StandardSetController we can show 10000 records(Limit 10000 because Database.QueryLocater fetch 10000 records) for PAGINATION , but i have 300000 contacts how can i paginate. and Offset Limit is 2000 records

  • @Ratan OFFSET is limited to 2k.
    – sfdcfox
    Jun 23, 2016 at 14:05
  • yes its only limit is 2K only for offset and for StandardSetController limit is 10000 Jun 23, 2016 at 14:09

2 Answers 2


You can either use client-side or server-side pagination. Either way, you won't be able to use standard tools like StandardSetController or OFFSET.

Server-side, you need to use the @ReadOnly annotation to enable the 1,000,000 row limit, which might look like this:

@RemoteAction @ReadOnly public static SObject[] getRecords(Integer page) {
    SObject[] results = new SObject[0];
    for(SObject[] records: [SELECT ... FROM SObject WHERE ... LIMIT :page*200]) {
        results = records;
    return results;

From there, you just repeatedly call the value until you get all of your results:

var buffer = []
function getPage(i) {
    myController.getPage(i, function(event, data) {
         if(data.length) {
             data.forEach(function(v) {buffer.push(v)})

Client-side, it'd look more like this example from the docs:

var result = sforce.connection.query("select id, name from account"); 
var it = new sforce.QueryResultIterator(result); 
var buffer = [];
while (it.hasNext()) { 
    var account = it.next(); 

In either case, once the client's loaded all the data, it's up to you to implement client-side pagination, perhaps using jQuery, AngularJS, etc.

  • not clear can you elaborate in full details. any dynamic query required. Jun 24, 2016 at 10:09
  • 1
    @VipinIndora What's not clear? What have you tried? Either of the above examples should probably work verbatim within a larger framework.
    – sfdcfox
    Jun 24, 2016 at 16:24
  • can You have Full Example so that i can review and use it. if you have then its very highly appreciable . thanks in advance Jun 27, 2016 at 13:26

You will have to query the entire 300,000 contacts in your controller and hold them in a private list of contacts. You'll want a separate list of Contacts that you will use to display on the page. For pagination you will have to write your own code that will take the appropriate amount of Contacts from the private list and add them to the pagination list.

  • 3
    Unfortunately, the 135k view state limit would explode even in read-only mode. The data has to be sent client-side for rendering.
    – sfdcfox
    Jun 23, 2016 at 14:17

You must log in to answer this question.

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