The following error appears when you exceed the Apex Execution Governor Limit for SOQL queries: System.LimitException: Too many SOQL queries: 101
Salesforce Apex runs on a shared, multi-tenant platform where all customers share the same computing resources. To ensure no single customer's code monopolizes shared resources, Salesforce enforces governor limits. The SOQL query governor limit is capped at 100 queries per transaction context — including all SOQL queries fired by triggers, classes, flows, and API calls within that single context.
When this limit is exceeded, Salesforce throws the LimitException shown above.
Real-world example: An Apex trigger on the Account object queries related Contacts for each Account in a batch. If 101 Accounts are processed in a single transaction and the trigger fires one SOQL query per Account record (inside a for loop), the limit is exceeded on the 101st Account and the transaction fails.
Notes:
To fix this issue, refactor your Apex code so that the total number of SOQL queries fired within a single transaction context is fewer than 100.
If you need to run code asynchronously to avoid the limit in the current context, use the @future annotation, which executes the code in a separate, asynchronous transaction with its own governor limit allocation.
Since Apex runs on a multi-tenant platform, the Apex runtime engine strictly enforces limits to ensure code does not monopolize shared resources. Follow these best practices to stay within the 100-query limit:
000386220

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.