0

I have a set up where an external integration will bring 10,000 records at a time into my salesforce org (update transaction, not insert). I need to test if my triggers, S2S connection (which updates corresponding records in another org) etc will be fine when that happens.

However, i do not have that integration set up in lower environments. So i need to simulate updating 10,000 records in a single transactions.

I tried running anonymous apex

//query existing records
List<Contact> contactsToBeUpdated = [Select Id, employeeType__c from Contact where Email LIKE 'DataMigration_%'];
for(Contact c : contactsToBeUpdated){ c.EmployeeType__c = 'Blah';}
update contactsToBeUpdated;

While it is the last line i really want to test (updating the contacts), all that for loop causes CPU timeout limit, so i am not able to test it.

Unit test will not tell me if S2S can handle 10,000 record updates at a time or not (this is actually the most crucial part that we are worried about .. we don't quiet understand internal workings of S2S).

I tried using Data loader, and it breaks down 10,000 records into small chunks of 200 records each, so it is not simulating the real scenario.

Is there any way, i can update 10,000 records in a single transaction?

1 Answer 1

4

There is no Salesforce API that allows updating 10,000 records in a transaction.

I have a set up where an external integration will bring 10,000 records at a time into my salesforce org (update transaction, not insert).

This cannot take place in a transaction unless it's using some arcane internal functionality I've never heard of. Your integration may be sending 10,000 records in a Bulk API job, or perhaps simply in some unit of time, but it is almost certainly not in one transaction.

The SOAP and REST Collections APIs top out at 200 records per transaction. The Bulk API is not configurable vis-a-vis transaction size and is fixed at 200 records per transaction.

2
  • that helps. I will find out how that integration send updates. So if I test with 200 records in a transaction, it should be a safe enough test. Commented Mar 17, 2021 at 1:54
  • 3
    +1 You could theoretically use a CSV parser or something and parse out 10,000 records in Apex and update (e.g. as an Apex Rest call), but CPU limits makes that very ridiculously hard to do, as OP found out. In more realistic scenarios, updates of 200 at a time will suffice.
    – sfdcfox
    Commented Mar 17, 2021 at 2:16

You must log in to answer this question.

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