LoginSignup
1
3

More than 5 years have passed since last update.

処理レコード数のガバナ制限について

Posted at

2017年5月現在、1トランザクションでDML ステートメント、Approval.process、または database.emptyRecycleBin の結果として処理されるレコードの合計数は、最大10000件となっています。

ちょっとトリガの挙動を確認するために、開発者コンソールから10000レコード突っ込んで、その後ロールバックするという処理を実行した所、何故かガバナ制限でエラーとなってしまいました。

なぜ、エラーとなったか確認するため、以下のコードを実行してみました。

System.debug('Point1. DML Rows:' + Limits.getDMLRows());
Savepoint sp = Database.setSavepoint();
System.debug('Point2. DML Rows:' + Limits.getDMLRows());
List<Account> accounts = new List<Account>();
for(Integer i = 0 ; i < 1000 ; i++) {
    accounts.add(new Account(Name = String.valueOf(i).leftPad(5).replace(' ', '0')));
}
insert accounts;
System.debug('Point3. DML Rows:' + Limits.getDMLRows());
Database.rollback(sp);
System.debug('Point4. DML Rows:' + Limits.getDMLRows());

実行結果は以下のようになりました。

09:40:44:002 USER_DEBUG [1]|DEBUG|Point1. DML Rows:0
09:40:44:002 USER_DEBUG [3]|DEBUG|Point2. DML Rows:1
09:40:55:643 USER_DEBUG [9]|DEBUG|Point3. DML Rows:1001
09:40:56:371 USER_DEBUG [11]|DEBUG|Point4. DML Rows:1002

Database.setSavepoint、Database.rollbackの実行でも、1回につき1レコードの処理として加算されるようです。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3