I'm trying to display more than 10000 records in a single page with out pagination, after enabling readonly="true" governor limit of collection is increased from 1000 to 10000. I tried using transient keyword as well. But I'm not able to display more than 10k. could you please suggest me like which concept will help me to achieve the same.

<apex:page controller="Display10000" readOnly="true" >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!Accounts}" var="a">
            <apex:column value="{!a.name}"  />
            <apex:column value="{!a.phone}"  />
            <apex:column value="{!a.AccountNumber}"  />

public class Display10000 {
    public transient static List<Account> accList {get; set;}
    public transient static List<Account> accList1 {get; set;}
    public transient static Integer size{get;set;}
    public static List<Account> getAccounts(){
        accList = [Select Name,AccountNumber,Phone from Account];
        size = accList.size();
        return accList;
  • did you tried adding ReadOnly annotation at the apex method?
    – Ysr Shk
    Oct 6, 2020 at 7:15
  • Displaying so many records at once sounds...not good. That's simply just too much information to fit on a screen. There's no chance anyone is going to sit and scroll through that many records. It'd help if you explained your motivation for doing this (why display it all on one page? why avoid pagination?)
    – Derek F
    Oct 6, 2020 at 11:26

1 Answer 1


Salesforce Visualforce collection iteration using apex:repeat supports a maximum of 10000 records in a read only transaction. If you want to go higher you need to use a different technique for fetching and iterating the data to display.

One approach is to handle the data table using JavaScript, using a Visualforce Remoting function that allows you to query the data for display (possibly in chunks, if you want to handle very large volumes of data or want to improve the user experience by loading the data in as the user scrolls - sometimes called infinite scrolling), then use JavaScript to iterate and insert this data into your DOM for presentation.

If your query has an ORDER BY that allows for completely deterministic ordering (e.g. if you want to order by Account Name but may have more than one Account with the same Name you should order by the name AND the ID), you can use the combination of ORDER BY fields to provide the equivalent of the SOQL OFFSET functionality without the 2000 record limit by essentially passing the last set of values for these ORDER BY fields to the VF Remoting function to tell it where to pick up. For example:

public static List<Account> getAccounts(String fromName, String fromId, Integer size) {
    String query = 'SELECT Id, Name, ... FROM Account';

    if (fromName != null && fromId != null) {
        query += ' WHERE Name > :fromName OR (Name = :fromName AND Id > :fromId)';

    query += ' ORDER BY Name ASC, Id ASC LIMIT :size';

    return Database.query(query);

You then have to always collect the Name and Id from the last Account in the list in your JavaScript for sending these details back for the subsequent call to the remote function. This is then done iteratively to build the complete picture. (NB: This code is bare bones and should have error handling etc. added to it.)

WARNING: If you just keep loading and loading until you have all the data you will:

  • Give a poor user experience as the page may take a very long time to load
  • Make the browser take an even longer time to render the page once you add the data to the DOM
  • Actually cause the browser to crash if there's simply too much data

In all honesty, there are very few cases where it is actually worth loading more than a few dozen records for users to view in a web page; if you actually want some form of report for offline analysis you are likely better off exporting the data rather than rendering it in a Visualforce page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.