3

Mystery of DML operation: if SObject doesn't have neither triggers nor workflow rules, how insert operation on it can cause exhausting of SOQL query limit? I have faced today again with exhausting of SOQL query limit, so I have been trying to examine thoroughly each line of code. Generally situation was following. I was trying to write a test method, which should have performed one insert operation amongst the others preparations before test. The problem was that this single insert used about 87 SOQL queries. Other preparations took about 67 SOQL queries, and test itself used about 30-40 SOQL queries, so I couldn't put this insert neither in preparation part nor after Test.startTest() statement. So I had to investigate what is happening with this insert. The original object had two triggers, one of them called service method which made another insert operation on object that didn't have neither triggers nor workflow rules, but this insert used 6 SOQL queries. This was quite frustrating.

1

Finally I have found answer. This second SObject has two relation field, one master-detail relationship field and one lookup. So insert of this SObject fires the trigger of SObject which is connected to this object through master-detail relationship.

  • A common issue when the master record has Roll Up Summary Field (RSF) on its detail record; including implicit master-detail RSF such as Opportunity.amount that is a RSF of OpportunityLineItem – cropredy Dec 27 '13 at 1:55
  • Yep, the parent record triggers will only get fired if there is a rollup summary. – Ralph Callaway Jan 31 '14 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.