+ Start a Discussion
dmchengdmcheng 

DML limit of 1000 applicable in batch Apex?

Hello.  the documentation for each DML statement says that "You can pass a maximum of 1000 sObject records to a single  

method."

 

Does this apply in Batch Apex as well?  I need to iterate through thousands of imported records and create a list of 2000+ opportunities that will be inserted on a monthly basis.

 

I understand that heap size could be an issue if my opps list gets even larger than 2000, so perhaps I'll just have to manually chunk the insert anyway, but I'd like to know if the 1000 obj DML limit applies in batch Apex.

 

Thanks

David

Best Answer chosen by Admin (Salesforce Developers) 
rungerrunger

This particular limit no longer exists.  You've found a documentation bug.

All Answers

bob_buzzardbob_buzzard

My understanding is that the regular governer limits apply to batch apex, but are reset each time your <batch>.execute method is called.  Thus if I find that I am hitting limits, I can scale down the number of records that are processed each time the execute method is called.

rungerrunger

This particular limit no longer exists.  You've found a documentation bug.

This was selected as the best answer
dmchengdmcheng

Bob and Rich, thanks for your replies.  That's good to know.

 

@Rich - BTW, is there a web page or email address where we can submit documentation bugs?

 

Thanks

David

rungerrunger

This particular bug was already reported last week, and the fix should appear online soon.

salesforcecrapsalesforcecrap

Hmm... I've got a batch apex job that just ran and it is throwing:

 

System.LimitException: Too many DML rows: 10001

 

Can any of you fellow hackers give me any tips? I thought the governor limit did not apply to Batch Apex jobs?

rungerrunger

The number of rows per batch is 10k.  The limit we are referring to above that went away was the 1000 collection size limit.

salesforcecrapsalesforcecrap

Ah, thanks Runger.

 

salesforcecrapsalesforcecrap

But, from the doco it seems that if start() returns a QueryLocator I don't have the governor limit?

 

"Use theDatabase.QueryLocatorobject when you are using a simple query (SELECT) to generate the scope of objects used in the batch job. If you use a querylocator object, the governor limit for the total number of records retrieved by SOQL queries is bypassed. For example, a batch Apex job for the Accountobject can return aQueryLocator

for all account records (up to 50 million records) in an organization."

 

 

rungerrunger

That's the query to get the initial data set.  It's saying the SoqlRows limit doesn't apply to that initial query.

The whole point of batch apex is to break up handling of large data sets into multiple batches.  Each batch has the similar governor limits as any other request.  Batch Apex just helps you manage work against large data sets effectively across multiple requests.

salesforcecrapsalesforcecrap

Thanks. That's how I understand it.


I'm going to start a new thread with my specific question with some additional information.