I have a test class which calls a visual force page and executes methods in apex controller. Currently the test class is failing on too many soql limits exception. I am trying to debug which soql query is executed multiple times. What is the best way to identify how many soqls are executed, identify any loops in the debug log? What setting in the debug log will tell me how many loops are there, how many soql queries are executed? Thanks Buyan

  • you can run the test class from developer console and you will see the howmany soqls are executed Aug 12 '16 at 3:11
  • Increase the log level for "Profiling" and it will tell you how many times each query is executed amount a lot of other info. Or a simple review of the debug log will reveal the offending query if it is in a loop (pretty easy to spot)
    – Eric
    Aug 12 '16 at 3:13
  • Unless the codebase is insanely huge with multiple dependencies, I tend to just look at the code and see where the SOQL statements are. It's usually pretty obvious if the SOQL statements are within a for loop. It just becomes hard if it triggers something, that triggers something else... and so on.
    – Nick Cook
    Aug 12 '16 at 4:15

You can define log level as follows to view finest logs.

Log Level

For more information refer Debug log levels

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.