0

Title says it all. I'm making a standard TestDataFactoryClass. I want it to insert 30,000 records. For example: 9,999 records in 3 objects. I get an error: Too many SOQL queries at 10,000 records.

References:

https://trailhead.salesforce.com/en/apex_testing/apex_testing_data?id=apex_testing

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_utility_classes.htm

1
  • 1
    You shouldn't be getting a query limit...but rather a DML Rows limit. Can you post the error message verbatim?
    – Adrian Larson
    Feb 5, 2017 at 0:21

1 Answer 1

2

It can't be done. Even if you don't have a single trigger, the limit of DML Rows is 10,000. That's for your entire transaction, not per statement. Since your entire test is a single transaction, you're limited to that many records and there's no way you can create more.

Note from Execution Governors and Limits:

Total number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin: 10,000

You can even verify in your test itself:

system.assertEquals(10000, Limits.getLimitDmlRows());

If you want to act on more than 10,000 records, you can do so using SeeAllData=true, though it should be used with care.

You must log in to answer this question.

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