System.LimitException: Too many SOQL queries: 101The classic SOQL-in-a-for-loop. Every Salesforce developer has written this pattern. It works perfectly in Sandbox with 10 test records. Then it crashes Production when real data volumes hit 1,000+ records.
12,000 developers search for this exact error every month. Most at 2:00 AM during a production incident. This page shows them exactly how Jataka catches this before the merge.
Maximum SOQL queries allowed in a single transaction
The query that crashes your Production at 2:00 AM
Average downtime from this single error
Salesforce enforces this limit to prevent runaway queries from consuming shared resources. When you hit 101, the entire transaction rolls back. If this happened in a trigger, every record in that batch fails. If it happened in a Flow, the user sees a generic error with no explanation.
This code passes code review. It passes PMD. It passes SonarQube. It works in Sandbox. Then it crashes Production.
// ❌ BAD: SOQL inside a for loop
// This works in Sandbox with 10 records
// Crashes in Production with 1,000+ records
public void processAccounts(List<Id> accountIds) {
for (Id accId : accountIds) {
// Each iteration runs a query!
List<Contact> contacts = [
SELECT Id, Name, Email
FROM Contact
WHERE AccountId = :accId
];
// Process contacts...
for (Contact c : contacts) {
c.Email = c.Email.toLowerCase();
}
update contacts;
}
}Why static analysis misses this: PMD and SonarQube scan text. They see a query inside a loop and might flag it. But they can't know if that loop will run 5 times or 500 times. Only runtime execution reveals the truth.
When this code runs in Jataka's Sandbox, we catch the limit breach before it ever reaches Production.
SOQL Queries
127/100
Query Rows
4,832/50,000
DML Statements
23/150
CPU Time
842ms/10,000ms
SOQL Limit Breach Detected
Transaction executed 127 SOQL queries. Limit is 100. Found SOQL inside for loop at line 8.
Bulkify the query. Move it outside the loop. Process records in memory.
// ✅ GOOD: Bulkified query
// One query for all accounts
public void processAccounts(List<Id> accountIds) {
// Single query outside the loop
List<Contact> allContacts = [
SELECT Id, Name, Email, AccountId
FROM Contact
WHERE AccountId IN :accountIds
];
// Process in memory
for (Contact c : allContacts) {
c.Email = c.Email.toLowerCase();
}
// Single update
update allContacts;
}Result: 1 SOQL query instead of 127. The transaction completes in 200ms. Production stays online.
Stop 2 AM firefighting
Book a demo and watch Jataka block this exact error in real-time. Your developers sleep through the night.