Platform
Too many DML rows: 10001 in Apex
Distinguish DML rows from statements and reduce record fan-out or split large updates across recoverable transactions.
One update statement can exceed the DML row limit. Bulkifying a loop solves statement count, but the records still count.
The governor reference sets the DML row budget at 10,000 per transaction. A single list with 10,001 records exceeds it, even though your code issues one statement. Related automation can also consume the budget while your save runs.
Trace the records touched by one input
Start with the operation’s input count, then map its related writes. If one parent update also modifies many children, a seemingly small scope can generate a large total. Include repeated updates of the same records in the investigation rather than counting only unique IDs in the input.
Place measurements around the suspected service:
Integer beforeRows = Limits.getDmlRows();
// Run the operation under investigation here.
System.debug(LoggingLevel.WARN,
'DML rows used: ' + (Limits.getDmlRows() - beforeRows));
System.debug(LoggingLevel.WARN,
'Transaction ceiling: ' + Limits.getLimitDmlRows());
These Limits methods make the increase visible. Include a parent that has many children in the test set. Averages can hide the single parent that makes the transaction fail.
Reduce writes before splitting work
Remove updates that set a field to its existing value. Check whether several automation paths write the same records independently. Consolidating those changes can reduce work while preserving the business result.
Partial-success DML changes error handling; it doesn’t remove governor limits. Database.update(records, false) is useful for inspecting per-record failures, but it isn’t a way to process an unlimited collection in one transaction.
When the work spans many records, use a deliberate asynchronous boundary. Batch Apex processes separate scopes as separate transactions. Choose the scope using the downstream fan-out as well as the number of records passed to execute.
Make partial completion part of the design
A batch can commit some scopes while another fails. Store a job reference, summarize failures and decide whether the operator should retry individual records or a complete scope. A retry should not apply a cumulative adjustment twice.
For imports, verify which controls the chosen API exposes. Don’t assume a Bulk API 2.0 ingest job gives you the same client-controlled batch sizing as another API. Often the change belongs in the automation that fires during the import.
Your release test should include a mixed scope: ordinary parents, one large parent and a record rejected by validation. Assert the intended updates and the recovery behavior. The related DML statement guide covers the other limit that often appears in the same investigation.