Home>
Question matters

I want to get SOQL records every 1000 records in Apex of Salesfoce.

Concrete example

For example, if the Lead object contains a lot of data
Respectively,
1-1000
1001-2000
2001-3000
......
And want to get the data. (Due to the balance of governor restrictions)

Other

-Batch processing does not reach this purpose, so it is not possible.
-Since the object ID is recognized as not a serial number, I don't think it can be processed from 1 to 1000 in the where clause.
・ I searched online, but couldn't find a good method.

  • Answer # 1

    How about offset?
    https://developer.salesforce.com/docs/atlas.ja-jp.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_offset.htm

    If you only want to get it, you can significantly relax the governor limit by setting SOQL to Readonly.
    https://developer.salesforce.com/docs/atlas.ja-jp.apexcode.meta/apexcode/apex_classes_annotation_ReadOnly.htm