Q: 9
A developer has identified a method in an Apex class that performs resource intensive actions in
memory by iterating over the result set of a SOQL statement on the account. The method also
performs a DML statement to save the changes to the database.
Which two techniques should the developer implement as a best practice to ensure transaction
control and avoid exceeding governor limits'*
Choose 2 answers
Options
Discussion
I get why people pick B since partial DML saves valid data, but the question specifically says avoid governor limits and ensure transaction control. So C lets you monitor resource consumption, and D (Savepoint) is for rolling back in case you hit a limit. Pretty sure it's C and D, unless I'm missing something!
C/D? I don't think B fits because partial DML helps with validity, but the question asks about governor limits usage and transaction control. System.Limits is your friend for monitoring, and Savepoint gives rollback capability. Pretty sure it's C and D, but open to arguments.
Its B and D. Had something like this in a mock, and Savepoint helps with transaction control but partial DML avoids bad data errors. Not sure about C since monitoring limits doesn't actually prevent limits from being hit.
Be respectful. No spam.