0

The documentation states:

The maximum record limit for StandardSetController is 10,000 records. Instantiating StandardSetController using a query locator returning more than 10,000 records causes a LimitException to be thrown. However, instantiating StandardSetController with a list of more than 10,000 records doesn’t throw an exception, and instead truncates the records to the limit.

Does this apply (for the QueryLocator)

  • per instance of ApexPages.StandardSetController within a transaction?

1 Answer 1

1

The answer, sadly, is NO.

The limit applies across all ApexPages.StandardSetController objects created in the transaction

Proof

OrderItem with 4000 assets - create 2 SSC (8000 rows)

for (Integer i = 0; i < 2; i++) {

    ApexPages.StandardSetController ssc = 
        new ApexPages.StandardSetController(
                Database.getQueryLocator(
                    [SELECT Id FROM Asset WHERE OrderItem__c = '802630000012JJG']));

}

RESULT: Success

OrderItem with 4000 Assets - create 3 SSC (12000 rows)

for (Integer i = 0; i < 3; i++) {

   ApexPages.StandardSetController ssc = 
        new ApexPages.StandardSetController(
                Database.getQueryLocator(
                    [SELECT Id FROM Asset WHERE OrderItem__c = '802630000012JJG']));

}

RESULT: System.LimitException: Too many query locator rows: 10001

Why might this be a problem for you?

Imagine you have a VF page that displays multiple pageable lists, each represented by a StandardSetController instance.

  • List1 has 2,500 rows
  • List2 has 3,000 rows (cumulative 5,500)
  • List3 has 5,000 rows (cumulative 10,500)

No list will display and the controller will blow up with an uncatchable limits exception. Assuming you are locked into this design, you'll have to count the rows first for each list, and, if over 10,000, decide how to adjust the SOQL Limit n value for the lists (like, do you favor the first list over the next? or is some list more business-useful?)

1
  • 3
    Or if you have a page where this might be an issue, move to SPA architecture. You can annotate the page @ReadOnly and retrieve boatloads of records, then manage pagination on the front end. It's worked well for me in the past with angular.
    – Adrian Larson
    Aug 19, 2019 at 21:39

You must log in to answer this question.

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