Salesforce governor limits reference

Winter '27 API 68.0 Checked against the official docs on Source: Apex Developer Guide: Execution Governors and Limits

Quick answer

In a synchronous Apex transaction you get 100 SOQL queries, 150 DML statements, 50,000 query rows, 10,000 DML rows, 100 callouts, 10 MB of heap and 10 seconds of CPU time. Asynchronous Apex raises SOQL queries to 200, heap to 25 MB and CPU time to 60 seconds. Exceeding a limit throws an exception you cannot catch.

54 limits

Which limit did I hit?

Match the error message from a debug log or a failed transaction to its limit. Numbers in the message are the limit plus one, because the exception is thrown on the first call over the limit.

Error message Limit that was exceeded Common fix
Too many SOQL queries: 101 100 SOQL queries per synchronous transaction (200 asynchronous) Move queries out of loops. Query once for the whole set of records into a Map, and check for the same query being run in triggers, flows and helper classes in the same transaction.
Too many query rows: 50001 50,000 records retrieved by SOQL queries per transaction Add selective filters, query only what you need, aggregate in SOQL, or move the work to Batch Apex.
Too many DML statements: 151 150 DML statements per transaction Collect records in a List and run one DML statement outside the loop.
Too many DML rows: 10001 10,000 records processed by DML per transaction Process the records in chunks with Batch Apex or Queueable Apex.
Apex CPU time limit exceeded 10,000 ms CPU time synchronous (60,000 ms asynchronous) Look for nested loops, repeated work and heavy string or collection handling. Use Maps for lookups, and move long work to async Apex. Use a debug log to find the slow method.
Apex heap size too large 10 MB heap synchronous (25 MB asynchronous) Query fewer fields and rows, avoid holding large lists or strings, and process data in batches.
Too many callouts: 101 100 callouts per transaction Reduce the number of calls, batch requests where the API allows it, or split the work across async jobs.
Too many future calls: 51 50 future method calls per Apex invocation Combine work into one future call, or use Queueable Apex.
Too many Queueable jobs added to the queue: 51 50 System.enqueueJob calls per synchronous transaction (1 asynchronous) Enqueue one job that processes many records, and chain the next job from inside it.
Too many SOSL queries: 21 20 SOSL queries per transaction Combine searches into one SOSL query across several objects.
Too many Email Invocations: 11 10 sendEmail calls per transaction Build a list of messages and send them with one Messaging.sendEmail call.
Maximum trigger depth exceeded Trigger stack depth of 16 Find the update that re-fires the trigger. Act only on changed fields, and use a static Set of processed record IDs as a guard if needed.

Per-transaction Apex limits

These limits count for each Apex transaction. For Batch Apex they reset for each execute call. Where a row shows one value, it applies to both synchronous and asynchronous Apex. Scheduled Apex is asynchronous, but synchronous limits apply to it.

Limit Synchronous Asynchronous
Total number of SOQL queries issued # Each parent-child relationship subquery counts as an extra query. Custom metadata type queries are not limited. Read it in Apex: Limits.getLimitQueries() 100 200
Total number of records retrieved by SOQL queries # Read it in Apex: Limits.getLimitQueryRows() 50,000 Same for synchronous and asynchronous Apex.
Total number of records retrieved by Database.getQueryLocator # Read it in Apex: Limits.getLimitQueryLocatorRows() 10,000 Same for synchronous and asynchronous Apex.
Total number of SOSL queries issued # Read it in Apex: Limits.getLimitSoslQueries() 20 Same for synchronous and asynchronous Apex.
Total number of records retrieved by a single SOSL query # 2,000 Same for synchronous and asynchronous Apex.
Total number of DML statements issued # Includes insert, update, upsert, delete, undelete, merge, Database methods, Approval.process, Database.convertLead and System.runAs. Read it in Apex: Limits.getLimitDmlStatements() 150 Same for synchronous and asynchronous Apex.
Total number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin # Read it in Apex: Limits.getLimitDmlRows() 10,000 Same for synchronous and asynchronous Apex.
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements # Recursion that fires a trigger starts a new invocation, so the depth limit is tighter than for plain recursive calls. 16 Same for synchronous and asynchronous Apex.
Total number of callouts (HTTP requests or web services calls) in a transaction # Read it in Apex: Limits.getLimitCallouts() 100 Same for synchronous and asynchronous Apex.
Maximum cumulative timeout for all callouts (HTTP requests or Web services calls) in a transaction # 120 seconds Same for synchronous and asynchronous Apex.
Maximum number of methods with the future annotation allowed per Apex invocation # Read it in Apex: Limits.getLimitFutureCalls() 50 0 in batch and future contexts; 50 in queueable context
Maximum number of Apex jobs added to the queue with System.enqueueJob # Read it in Apex: Limits.getLimitQueueableJobs() 50 1
Total number of sendEmail methods allowed # Read it in Apex: Limits.getLimitEmailInvocations() 10 Same for synchronous and asynchronous Apex.
Total heap size # Exceeding it throws an uncatchable System.LimitException. Email services heap size is 50 MB. CPU and heap are related: heavy heap use makes the CPU limit more likely. Read it in Apex: Limits.getLimitHeapSize() 10 MB 25 MB
Maximum CPU time on the Salesforce servers # Counts Apex, package code and workflows in the transaction, and application-server CPU spent in DML. Database time for DML, SOQL and SOSL, and waiting for callouts, do not count. Read it in Apex: Limits.getLimitCpuTime() 10,000 milliseconds 60,000 milliseconds
Maximum execution time for each Apex transaction # 10 minutes Same for synchronous and asynchronous Apex.
Maximum number of push notification method calls allowed per Apex transaction # 10 Same for synchronous and asynchronous Apex.
Maximum number of push notifications that can be sent in each push notification method call # 2,000 Same for synchronous and asynchronous Apex.
Maximum number of EventBus.publish calls for platform events configured to publish immediately # 150 Same for synchronous and asynchronous Apex.
Maximum number of rows across all Apex cursors per transaction # 50 million Same for synchronous and asynchronous Apex.
Maximum number of Cursor.fetch calls per transaction # 100 Same for synchronous and asynchronous Apex.
Maximum number of rows across all Apex pagination cursors per transaction # 100,000 Same for synchronous and asynchronous Apex.
Maximum number of Apex pagination cursor instances per transaction # 50 Same for synchronous and asynchronous Apex.
Maximum number of rows retrieved per page from an Apex pagination cursor # 2000 Same for synchronous and asynchronous Apex.

Certified managed package cumulative limits

Certified managed packages (AppExchange security-reviewed) get their own per-namespace limits. Across all namespaces in one transaction the cumulative limit is 11 times the per-namespace limit. Heap, CPU time, execution time and the number of unique namespaces are shared by the whole transaction.

Limit Value
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

Salesforce Platform Apex limits

These limits are enforced by the platform, not per Apex transaction.

Limit Value
Asynchronous Apex method executions per 24-hour period (batch, future, Queueable and scheduled Apex) # This is the DailyAsyncApexExecutions org limit. For Batch Apex, start, execute and finish each count. Check remaining capacity with the REST API limits resource or OrgLimits.getMap(). 250,000 or the number of applicable user licenses in your org multiplied by 200, whichever is greater
Batch, Queueable and future method executions that can be enqueued in 24 hours, including elastic executions processed at a throttled rate (beta) # This is the DailyAsyncApexElasticExecutions org limit. The org's daily asynchronous Apex method executions limit plus either the org's licensed daily asynchronous Apex method executions limit or 2 million executions, whichever is less
Maximum number of Apex cursor instances per 24-hour period # 10,000
Maximum cumulative number of new cursor rows and pagination cursor rows per 24-hour period # 100 million
Maximum number of Apex pagination cursor instances per 24-hour period # 200,000
Synchronous concurrent transactions for long-running transactions that last longer than 5 seconds for each org # HTTP callout processing time is not included when calculating this limit. Based on the number of applicable licenses; a ratio of 100 licenses to one concurrent long-running Apex transaction. Minimum limit is 10. Maximum limit is 50
Maximum number of Apex classes scheduled concurrently # 100. In Developer Edition orgs, the limit is 5
Maximum number of batch Apex jobs in the Apex flex queue that are in Holding status # 100
Maximum number of batch Apex jobs queued or active concurrently # 5
Maximum number of batch Apex job start method concurrent executions # 1
Maximum number of batch jobs that can be submitted in a running test # 5
Maximum number of test classes that can be queued per 24-hour period (production orgs other than Developer Edition) # The greater of 500 or 10 multiplied by the number of test classes in the org
Maximum number of test classes that can be queued per 24-hour period (sandbox and Developer Edition orgs) # The greater of 500 or 20 multiplied by the number of test classes in the org

Static Apex limits

Fixed values that do not vary by transaction type.

Limit Value
Default timeout of callouts (HTTP requests or Web services calls) in a transaction # 10 seconds
Maximum size of callout request or response (HTTP request or Web services call) # Request and response sizes count towards the total heap size. 6 MB for synchronous Apex or 12 MB for asynchronous Apex
Maximum SOQL query run time before Salesforce cancels the transaction # 120 seconds
Maximum number of class and trigger code units in a deployment of Apex # 7500
Apex trigger batch size # The trigger batch size for platform events and Change Data Capture events is 2,000. 200
For loop list batch size # 200
Maximum number of records returned for a Batch Apex query in Database.QueryLocator # 50 million

Size-specific Apex limits

Limits on the size of Apex code.

Limit Value
Maximum number of characters for a class # 1 million
Maximum number of characters for a trigger # 1 million
Maximum amount of code used by all Apex code in an org # Does not apply to managed packages (1GP or 2GP) or to code in classes with @isTest. Scratch orgs allow 10 MB. You can ask Salesforce Support to raise it. 6 MB
Method size limit # Larger methods throw an exception when run. 65,535 bytecode instructions in compiled form

Check limits in your own code

The Limits class tells you what a transaction has used and what it may use. Log it while debugging, or stop work early when you get close.

System.debug('SOQL: ' + Limits.getQueries() + ' of ' + Limits.getLimitQueries());
System.debug('DML statements: ' + Limits.getDmlStatements() + ' of ' + Limits.getLimitDmlStatements());
System.debug('CPU ms: ' + Limits.getCpuTime() + ' of ' + Limits.getLimitCpuTime());
System.debug('Heap bytes: ' + Limits.getHeapSize() + ' of ' + Limits.getLimitHeapSize());

To see how much of the 24-hour asynchronous Apex capacity is left, call the REST API limits resource or OrgLimits.getMap().

Staying under the limits

  • Bulkify. Triggers receive up to 200 records at once, so never run a query or DML statement inside a loop over them.
  • Query once, use a Map. Load related records into a Map<Id, SObject> before the loop instead of querying per record.
  • Be selective. Filter on indexed fields, select only the fields you need, and add LIMIT where it makes sense.
  • Move heavy work to async. Queueable or Batch Apex gets higher SOQL, heap and CPU limits and splits large jobs into separate transactions.
  • Watch the whole transaction. Triggers, flows and packages that run in the same transaction share the same limits.

Frequently asked questions

What are Salesforce governor limits?

Governor limits are runtime caps that the Apex engine enforces so that no single piece of code can monopolize the shared, multitenant platform. When code goes over a limit, Salesforce throws a runtime exception that cannot be handled.

How many SOQL queries can I run in one Apex transaction?

You can issue 100 SOQL queries in a synchronous transaction and 200 in an asynchronous one. Each parent-child relationship subquery counts as an extra query. Queries against custom metadata types are not limited.

What is the difference between synchronous and asynchronous limits?

Asynchronous Apex (Batch Apex, future methods and Queueable Apex) gets higher limits for SOQL queries (200 vs 100), heap size (25 MB vs 10 MB) and CPU time (60,000 ms vs 10,000 ms). Scheduled Apex is asynchronous, but the synchronous limits apply to it.

What is the Apex heap size limit?

The current Apex Developer Guide lists 10 MB for synchronous Apex and 25 MB for asynchronous Apex. Older articles and books often quote 6 MB and 12 MB, which are the values that the guide listed in earlier releases. The 6 MB and 12 MB figures still apply to the maximum callout request or response size.

Can I catch a governor limit exception in Apex?

No. A System.LimitException cannot be caught, so a try-catch block will not save the transaction. The fix is to stay under the limits, which you can check at runtime with the Apex Limits class.

How do I check how close my code is to a limit?

Use the Limits class. Methods such as Limits.getQueries() and Limits.getDmlStatements() return how much of a limit has been used, and the matching Limits.getLimit methods return the maximum, for example Limits.getLimitQueries().

Do managed packages share my limits?

Certified managed packages, which have passed the AppExchange security review, get their own per-namespace limits for most per-transaction limits. The cumulative limit across namespaces is 11 times the per-namespace limit. Heap size, CPU time and execution time are shared by the whole transaction. Non-certified packages use your org limits.

More tools

SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Salesforce changes its platform every release, so confirm against the official page before relying on a value.