I need to query more than 50000 records and store it in a List variable. i know there is a governor limit which prevents it. please let me know if this can be accomplished without going for a batch class.

will getQueryLocator work in a normal class... please help.

  • What you have tried so far? Commented Apr 29, 2019 at 9:59
  • Why do you need more than 50,000 rows? What are you attempting to do?
    – sfdcfox
    Commented Apr 29, 2019 at 11:28

1 Answer 1


Since Simmer '18, The SOQL Count() Function Doesn’t Count (As Much) Toward Limits so you can count way more than 50,000 records.

If you are working from a Visaulforce page, setting readOnly="true" lifts the limit to 1,000,000 rows (see e.g. Setting Read-Only Mode for an Entire Page) but other limits such as the heap size still apply.

But the general solution when wanting to work with large numbers of rows is to move to asynchronous Apex such as batchable where QueryLocator can be used.


You must log in to answer this question.

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