Due to the nature of multitenancy and the fact we are sharing resources, governor limits are in place to ensure that all resources are allocated as expected to each.
There are different types of governor limits
Per-Transaction Apex Limits: These limits count for each Apex transaction. For Batch Apex, these limits are reset for each execution of a batch of records in the execute method.
Per Transaction Certified Managed Package Limits: If a managed package developed by a Salesforce ISV has passed security review, they are provided with generally higher per-transaction limits.
Lightning Platform Apex Limit: These limits aren’t specific to an Apex Transaction and are enforced by the Lightning platform.
Static Apex Limit: Apex Limits that are applied across all transactions.
Size-Specific Apex Limit: Apex Limits related to the size of code.
Miscellaneous Apex Limit: Other Limits!
Email Limits
Push Notification Limits
Flow Limits
Per-Transaction Apex Limits:
1 In a SOQL query with parent-child relationship subqueries, each parent-child relationship counts as an extra query. These types of queries have a limit of three times the number for top-level queries. The limit for subqueries corresponds to the value that Limits.getLimitAggregateQueries() returns. The row counts from these relationship queries contribute to the row counts of the overall code execution. This limit doesn’t apply to custom metadata types. In a single Apex transaction, custom metadata records can have unlimited SOQL queries. In addition to static SOQL statements, calls to the following methods count against the number of SOQL statements issued in a request.
Per-Transaction Certified Managed Package Limits
Certified managed packages—managed packages that have passed the security review for AppExchange—get their own set of limits for most per-transaction limits. Salesforce ISV Partners develop certified managed packages, which are installed in your org from AppExchange and have unique namespaces.
Here’s an example that illustrates the separate certified managed package limits for DML statements. If you install a certified managed package, all the Apex code in that package gets its own 150 DML statements. These DML statements are in addition to the 150 DML statements your org’s native code can execute. This limit increase means more than 150 DML statements can execute during a single transaction if code from the managed package and your native org both executes. Similarly, the certified managed package gets its own 100-SOQL-query limit for synchronous Apex, in addition to the org’s native code limit of 100 SOQL queries.
This table lists the cumulative cross-namespace limits.
Description | Cumulative Cross-Namespace Limit |
---|---|
Total number of SOQL queries issued | 1,100 |
Total number of records retrieved by Database.getQueryLocator | 110,000 |
Total number of SOSL queries issued | 220 |
Total number of DML statements issued | 1,650 |
Total number of callouts (HTTP requests or web services calls) in a transaction | 1,100 |
Total number of sendEmail methods allowed | 110 |
Lightning Platform Apex Limits
The limits in this table aren’t specific to an Apex transaction; Lightning Platform enforces these limits.
Static Apex Limits
1 The HTTP request and response sizes count towards the total heap size.
2 The Apex trigger batch size for platform events and Change Data Capture events is 2,000.
Size-Specific Apex Limits
1 This limit doesn’t apply to Apex code in first generation(1GP) or second generation(2GP) managed packages. The code in those types of packages belongs to a namespace unique from the code in your org. This limit also doesn’t apply to any code included in a class defined with the @isTest annotation.
2 Large methods that exceed the allowed limit cause an exception to be thrown during the execution of your code.
Miscellaneous Apex Limits
Connect in ApexFor classes in the ConnectApi namespace, every write operation costs one DML statement against the Apex governor limit. ConnectApi method calls are also subject to rate limiting. ConnectApi rate limits match Connect REST API rate limits. Both have a per user, per namespace, per hour rate limit. When you exceed the rate limit, a ConnectApi.RateLimitException is thrown. Your Apex code must catch and handle this exception.Data.com CleanIf you use the Data.com Clean product and its automated jobs, consider how you use Apex triggers. If you have Apex triggers on account, contact, or lead records that run SOQL queries, the SOQL queries can interfere with Clean jobs for those objects. Your Apex triggers (combined) must not exceed 200 SOQL queries per batch. If they do, your Clean job for that object fails. In addition, if your triggers call future methods, they’re subject to a limit of 10 future calls per batch.Event ReportsThe maximum number of records that an event report returns for a user who isn’t a system administrator is 20,000; for system administrators, 100,000.MAX_DML_ROWS limit in Apex testingThe maximum number of rows that can be inserted, updated, or deleted, in a single, synchronous Apex test execution context, is limited to 450,000. For example, an Apex class can have 45 methods that insert 10,000 rows each. If the limit is reached, you see this error: Your runallTests is consuming too many DB resources.SOQL Query PerformanceFor best performance, SOQL queries must be selective, particularly for queries inside triggers. To avoid long execution times, the system can terminate nonselective SOQL queries. Developers receive an error message when a non-selective query in a trigger executes against an object that contains more than 200,000 records. To avoid this error, ensure that the query is selective. See More Efficient SOQL Queries.
Email Limits
Inbound Email Limits
1 The maximum size of email messages for Email Services varies depending on character set and transfer encoding of the body parts. The size of an email message includes the email headers, body, attachments, and encoding. As a result, an email with a 35-MB attachment likely exceeds the 25-MB size limit for an email message after accounting for the headers, body, and encoding.
When defining email services, note the following:
- An email service only processes messages it receives at one of its addresses.
- Salesforce limits the total number of messages that all email services combined, including On-Demand Email-to-Case, can process daily. Messages that exceed this limit are bounced, discarded, or queued for processing the next day, depending on how you configure the failure response settings for each email service. Salesforce calculates the limit by multiplying the number of user licenses by 1,000; maximum 1,000,000. For example, if you have 10 licenses, your org can process up to 10,000 email messages a day.
- Email service addresses that you create in your sandbox can’t be copied to your production org.
- For each email service, you can tell Salesforce to send error email messages to a specified address instead of the sender’s email address.
- Email services reject email messages and notify the sender if the email (combined body text, body HTML, and attachments) exceeds approximately 25 MB (varies depending on language and character set).
Outbound Email: Limits for Single and Mass Email Sent Using Apex
Each licensed org can send single emails to a maximum of 5,000 external email addresses per day based on Greenwich Mean Time (GMT). For orgs created before Spring ’19, the daily limit is enforced only for emails sent via Apex and Salesforce APIs except for REST API. For orgs created in Spring ’19 and later, the daily limit is also enforced for email alerts, simple email actions, Send Email actions in flows, and REST API. If one of the newly counted emails can’t be sent because your org has reached the limit, we notify you by email and add an entry to the debug logs. Single emails sent using the email author or composer in Salesforce don’t count toward this limit. There’s no limit on sending single emails to contacts, leads, person accounts, and users in your org directly from account, contact, lead, opportunity, case, campaign, or custom object pages. In Developer Edition orgs and orgs evaluating Salesforce during a trial period, you can send to a maximum of 50 recipients per day, and each single email can have up to 15 recipients..
Keep these considerations in mind when sending emails:
- When sending single emails, you can specify up to 150 recipients across the To, CC, and BCC fields in each SingleEmailMessage. Each field is also limited to 4,000 bytes.
- If you use SingleEmailMessage to email your org’s internal users, specifying the user’s ID in setTargetObjectId means the email doesn’t count toward the daily limit. However, specifying internal users’ email addresses in setToAddresses means the email does count toward the limit.
- You can send mass email and list email to a maximum of 5,000 external email addresses per day per licensed Salesforce org. A day is calculated based on Greenwich Mean Time (GMT).
- The single email, mass email, and list email limits count duplicate email addresses. For example, if you have johndoe@example.com in your email 10 times that counts as 10 against the limit.
- API or Apex single emails can be sent to a maximum of 5,000 external email addresses per day.
- You can send an unlimited amount of email through the UI to your org’s internal users, which include portal users.
- You can send mass emails and list emails only to contacts, person accounts, leads, and your org’s internal users.
- In Developer Edition orgs and orgs evaluating Salesforce during a trial period, you can send to no more than 10 external email recipients per org per day using mass email and list email.
- You can’t send mass email using a Visualforce email template.
Push Notification Limits
An org can send up to 20,000 iOS and 10,000 Android push notifications per hour (for example, 4:00 to 4:59 UTC).
Asynchronous Callout Limits
When a continuation is executing, the continuation-specific limits apply. When the continuation returns and the request resumes, a new Apex transaction starts. All Apex and Visualforce limits apply and are reset in the new transaction, including the Apex callout limits.
Continuation-Specific Limits
The following are Apex and Visualforce limits that are specific to a continuation.
1 The timeout that is specified in the autogenerated Web service stub and in the HttpRequest objects is ignored. Only this timeout limit is enforced for a continuation.
2 When the continuation is executed, the Visualforce controller is serialized. When the continuation is completed, the controller is deserialized and the callback is invoked. Use the Apex transient modifier to designate a variable that is not to be serialized. The framework uses only serialized members when it resumes. The controller-state size limit is separate from the view state limit. See Differences Between Continuation Controller State and Visualforce View State.
3 This limit is for HTTP POST forms with the following content type headers: content-type=’application/x-www-form-urlencoded’ and content-type=’multipart/form-data’
Follow below guide form salesforce
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_limits_tips.htm