AD PLACEMENT - LEADERBOARD
Back to all guides
Salesforce Apex Logs & Webhook Guides

Resolving Salesforce SOQL Query Governor Limits

Governor Limits on SOQL

Salesforce enforces limits such as 100 SOQL queries per synchronous transaction. Exceeding them throws System.LimitException: Too many SOQL queries.

How to Spot It

In the debug log, count SOQL_EXECUTE_BEGIN events. If you see the same query inside a loop, that's the cause.

Fixes

  1. Bulkify: move queries outside loops and use collections (Map<Id, SObject>).
  2. Use SOQL for loops with WHERE Id IN :idSet.
  3. Cache: store query results in a Map and reuse.

Reading the Log

The FormatHub Salesforce Log Cleaner aggregates SOQL execute events with row counts, making it easy to spot repeated queries and total rows consumed.

AD PLACEMENT - STICKY FOOTER