I am in critical situation due to below error

"System.LimitException: Too many SOQL queries: 101"

Whenever we are moving any changeset to production we are getting the above error. We followed salesforce best practices to write apex classes and triggers. We tried Test.start() and Test.stop to refresh the soql query count but no use of this because we are having too many queries that are hitting in various triggers.

Also we are not able to see the full debug log due to 2MB size limit.

Is there any other way to overcome this?


  • 3
    you can review a code that cause it and find an issue in that triggers. you can also add something like if (Limit.getQueries() > 90) { throw new customException('Here'); } to get place where limit is almost out.
    – kurunve
    Commented Aug 25, 2016 at 8:03
  • 4
    You can make a support request to get the 2M limit raised and then use tools like this SOQL Extractor and Analyzer for Salesforce (awkward to get installed though - see its "Support" information for a workaround) to help review the logs. Typically you will see repeated queries caused by cycles in the trigger and workflow logic - not easy to find the cause or fix.
    – Keith C
    Commented Aug 25, 2016 at 8:04
  • 6
    You can also change the log levels to lessen the log size. Commented Aug 25, 2016 at 8:05
  • Try to make your trigger deactivatable per some custom setting... Commented Aug 25, 2016 at 8:05
  • @kurunve - 1. am not able to see the debug of the code i want due to maximum debug size reached. 2. could you please put example for limit.getQueries() Commented Aug 25, 2016 at 8:10

1 Answer 1


Open the Developer Console, choose Debug / Change Log Levels... Click Add/Change next to the top entry, set all categories to None, except Profiling, which you set to Finest. Next, run your tests, then check the logs. You'll get a list of queries executed, plus the class or trigger that called them, and the number of executions. You can use Profiling to quickly identify where the most usage is occurring.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .