You need to sign in to do that
Don't have an account?
Pankaj Mishra 39
Apex Trigger see only 200 records in one chunk
I am aware that Trigger can process in chunks of 1-200 records at a time, is there any way we can increase this record count?
Here is my case: I am inserting 10,000 records from Test class
and my Trigger has 4 SOQL queries, as Triggers are processed in chunks of 200 records, my Trigger will be fired 50 times in this case. However, in each call my SOQL will get accumulated towards SOQL limits and Trigger will fail when it is called 26th time with SOQL limit exception.
In my Trigger I need to have 4 SOQL anyhow and I cannot reduce that, I know that Batch is the best solution in such scenarios but my application need this processing in real time.
Any solution or workaround is highly appreciated.
Here is my case: I am inserting 10,000 records from Test class
and my Trigger has 4 SOQL queries, as Triggers are processed in chunks of 200 records, my Trigger will be fired 50 times in this case. However, in each call my SOQL will get accumulated towards SOQL limits and Trigger will fail when it is called 26th time with SOQL limit exception.
In my Trigger I need to have 4 SOQL anyhow and I cannot reduce that, I know that Batch is the best solution in such scenarios but my application need this processing in real time.
Any solution or workaround is highly appreciated.
You can not increase the number of records executed in a single execution context.
Why do you need to insert 10k records for a test class? A batch of 200 should suffice in testing all of the business logic of your code.
Write the test class to cover 200 records at a time. No need to go beyond that. "Any import processes you currently have running should continue to work with the Bulk API as it uses the same save logic and has the same processing side-effects as the SOAP API. To stay within the current governor and limits, records are processed 200 at a time from your batches. So if your triggers are written to process 200 records successfully you should be fine."
https://developer.salesforce.com/page/Loading_Large_Data_Sets_with_the_Force.com_Bulk_API
Pankaj, how is your user going to insert / update 10k records in one execution context?
Have you considering using singletons to prevent re-querying every batch executed in the test class?