{"id":1519,"date":"2026-09-06T11:00:00","date_gmt":"2026-09-06T05:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/"},"modified":"2026-09-06T11:00:00","modified_gmt":"2026-09-06T05:30:00","slug":"apex-governor-limits-explained","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/","title":{"rendered":"Apex Governor Limits Explained with Real Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Apex Governor Limits are the rules that cap how much work one piece of Apex code can do in a single transaction. They limit queries, DML statements, CPU time, memory and more. Every Salesforce developer meets them in the first week, usually through a red error message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will learn why limits exist, the limits you will hit most, how to check usage with the Limits class, and how to write code that stays safely inside them. This starts Level 4 of our developer series. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/soql-basics-first-query-apex\/\">SOQL Basics<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/dml-operations-in-apex\/\">DML operations in Apex<\/a> and the <a href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-multi-tenant-architecture-metadata\/\">multi-tenant architecture<\/a> post, which explains why limits are needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Apex Governor Limits?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex Governor Limits are hard limits that Salesforce enforces on every Apex transaction. A transaction is everything that runs from one start event, such as a button click or a record save, until the work finishes. If code goes over a limit, Salesforce stops it with a LimitException and rolls back the whole transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of an apartment building with one shared water tank. Each flat gets a fair daily share, so one family cannot empty the tank for everyone. Salesforce servers are that shared tank, and governor limits are each tenant&#8217;s fair share.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Apex Governor Limits Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Salesforce runs many customers on the same servers, which we call multi-tenancy. Apex Governor Limits stop one org&#8217;s slow code from hurting everyone else. Here is why Apex Governor Limits matter at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, a data load of 200 enrolments runs every trigger with 200 records at once.<\/li>\n\n<li>Also, a query inside a loop works with 5 records but fails with 200.<\/li>\n\n<li>Next, a large report job can run out of memory without warning.<\/li>\n\n<li>An integration that calls outside systems must respect callout limits.<\/li>\n\n<li>Finally, a LimitException cannot be caught, so the whole save fails.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So code that ignores limits works in testing and breaks in production.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Apex Governor Limits Work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex Governor Limits work per transaction. First, a transaction starts, for example when a user saves a record. Next, Salesforce starts counters for queries, DML, CPU time and other resources. Then each query, DML statement and loop adds to those counters. After that, if any counter passes its limit, Salesforce throws a LimitException. Finally, the whole transaction rolls back, and the user sees an error.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-1-1024x640.png\" alt=\"Apex Governor Limits diagram showing transaction start, counters, limit check, LimitException and rollback\" class=\"wp-image-1517\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-1-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-1-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">How Salesforce counts resources in every transaction.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Per-Transaction Limits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Most limits apply to one transaction, such as 100 SOQL queries in synchronous code. They reset when the next transaction starts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Synchronous vs Asynchronous Limits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Asynchronous Apex, such as Batch Apex and Queueable jobs, gets higher limits for some resources. For example, it gets 200 SOQL queries instead of 100 and more heap memory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Per-Org Limits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Some limits apply to the whole org over 24 hours, such as the number of asynchronous Apex executions. These matter for large orgs with many background jobs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Limits Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Limits class tells you how much of each resource your code has used so far. For example, Limits.getQueries() returns the queries used, and Limits.getLimitQueries() returns the maximum.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Most Common Apex Governor Limits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the per-transaction limits developers hit most often.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Resource<\/th><th>Synchronous limit<\/th><th>Asynchronous limit<\/th><\/tr><\/thead><tbody><tr><td>SOQL queries<\/td><td>100<\/td><td>200<\/td><\/tr><tr><td>Records returned by SOQL<\/td><td>50,000<\/td><td>50,000<\/td><\/tr><tr><td>DML statements<\/td><td>150<\/td><td>150<\/td><\/tr><tr><td>Records processed by DML<\/td><td>10,000<\/td><td>10,000<\/td><\/tr><tr><td>SOSL searches<\/td><td>20<\/td><td>20<\/td><\/tr><tr><td>CPU time<\/td><td>10,000 ms<\/td><td>60,000 ms<\/td><\/tr><tr><td>Heap size<\/td><td>6 MB<\/td><td>12 MB<\/td><\/tr><tr><td>Callouts<\/td><td>100<\/td><td>100<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Unsafe Code vs Limit-Safe Code<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares code that hits limits with code that stays safe.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Unsafe pattern<\/th><th>Limit-safe pattern<\/th><\/tr><\/thead><tbody><tr><td>Queries<\/td><td>SOQL inside a loop<\/td><td>One query before the loop<\/td><\/tr><tr><td>DML<\/td><td>insert inside a loop<\/td><td>One insert on a list<\/td><\/tr><tr><td>Lookups<\/td><td>Query per record<\/td><td>Map built from one query<\/td><\/tr><tr><td>Large data<\/td><td>Load everything in memory<\/td><td>SOQL for loop or Batch Apex<\/td><\/tr><tr><td>Records handled<\/td><td>Works for 1 record<\/td><td>Works for 200 records<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which is simple. Always write the limit-safe version, because triggers can receive up to 200 records at a time.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-2-1024x640.png\" alt=\"Apex Governor Limits diagram comparing unsafe code and limit-safe code\" class=\"wp-image-1518\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-2-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-2-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Unsafe code vs limit-safe code.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Apex Governor Limits Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s fix a real problem with Apex Governor Limits at Bright Path Tutors. A trigger on Enrolment__c needs each course&#8217;s fee. The first version queries inside a loop.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: The Code That Breaks<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ BAD: one query per enrolment\nfor (Enrolment__c e : Trigger.new) {\n    Course__c c = [SELECT Fee__c FROM Course__c WHERE Id = :e.Course__c];\n    e.Amount_Due__c = c.Fee__c;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With 5 enrolments, this runs 5 queries. However, a Data Loader batch of 200 enrolments needs 200 queries. That passes the limit of 100, so the whole load fails with &#8220;Too many SOQL queries: 101&#8221;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: The Limit-Safe Version<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ GOOD: one query for all enrolments\nSet&lt;Id&gt; courseIds = new Set&lt;Id&gt;();\nfor (Enrolment__c e : Trigger.new) {\n    courseIds.add(e.Course__c);\n}\n\nMap&lt;Id, Course__c&gt; courses = new Map&lt;Id, Course__c&gt;(\n    [SELECT Id, Fee__c FROM Course__c WHERE Id IN :courseIds]\n);\n\nfor (Enrolment__c e : Trigger.new) {\n    Course__c c = courses.get(e.Course__c);\n    if (c != null) {\n        e.Amount_Due__c = c.Fee__c;\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">First, we collect every course Id into a set. Next, one query loads all those courses into a map. Then the second loop reads each fee from the map, with no more queries. As a result, 200 enrolments use one query instead of 200.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Check Usage with the Limits Class<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>System.debug('SOQL used: ' + Limits.getQueries() + ' \/ ' + Limits.getLimitQueries());\nSystem.debug('DML used: ' + Limits.getDmlStatements() + ' \/ ' + Limits.getLimitDmlStatements());\nSystem.debug('CPU used: ' + Limits.getCpuTime() + ' ms \/ ' + Limits.getLimitCpuTime() + ' ms');\nSystem.debug('Heap used: ' + Limits.getHeapSize() + ' \/ ' + Limits.getLimitHeapSize());<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each pair shows the amount used and the maximum. Add these lines while testing to see how close your code gets to each limit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Read the Output<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example of the debug log for the safe version with 200 enrolments.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>USER_DEBUG [1]|DEBUG|SOQL used: 1 \/ 100\nUSER_DEBUG [2]|DEBUG|DML used: 0 \/ 150\nUSER_DEBUG [3]|DEBUG|CPU used: 38 ms \/ 10000 ms\nUSER_DEBUG [4]|DEBUG|Heap used: 51234 \/ 6000000<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Apex Governor Limits in the Debug Log<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The debug log also prints a summary of Apex Governor Limits usage at the end of each transaction. Look for the section called &#8220;LIMIT_USAGE_FOR_NS&#8221;. It lists every limit with the amount used, which helps you find the most expensive part of your code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">CPU Time and Heap Size<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">CPU time counts the time your Apex code and some automation spend running, not time waiting for the database. Long nested loops are the usual cause of CPU limit errors. Heap size is the memory your variables use. Large lists and big strings fill the heap, so use SOQL for loops and clear lists you no longer need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Apex Governor Limits<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Writing SOQL or DML inside loops.<\/li>\n\n<li>Testing with one record instead of 200.<\/li>\n\n<li>Trying to catch a LimitException, which is not possible.<\/li>\n\n<li>Building large strings or lists in memory without need.<\/li>\n\n<li>Using nested loops over two big lists instead of a map.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Apex Governor Limits<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Query once and use maps for lookups.<\/li>\n\n<li>Use one DML statement per object per transaction where possible.<\/li>\n\n<li>Test every trigger with 200 records.<\/li>\n\n<li>Move heavy work to Batch Apex or Queueable jobs.<\/li>\n\n<li>Check the Limits class and debug log summary during testing.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Write a trigger-style loop that sets each enrolment&#8217;s Course Name field from its parent course, using one query. Then check Limits.getQueries() after running it with 200 test records. Hint: reuse the set and map pattern from Step 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Apex Governor Limits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apex Governor Limits come up in every Salesforce developer interview, at every level. Here are the 21 questions asked most, with short answers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Apex Governor Limits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What are governor limits?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">They are limits Salesforce enforces on each Apex transaction, such as the number of queries and DML statements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: Why does Salesforce have governor limits?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because many customers share the same servers. So limits stop one org&#8217;s code from slowing down everyone else.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: What is a transaction in Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is all the work that runs from one starting event, such as a record save, until it finishes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: How many SOQL queries can a synchronous transaction run?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">100 queries. Asynchronous Apex gets 200.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: How many DML statements are allowed?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">150 DML statements per transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: How many records can DML process in one transaction?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">10,000 records in total.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: What is the CPU time limit?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">10,000 milliseconds for synchronous Apex and 60,000 milliseconds for asynchronous Apex.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Apex Governor Limits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: What error do you get when you run too many queries?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">System.LimitException: Too many SOQL queries: 101.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: Can you catch a LimitException?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. It cannot be caught, so the transaction fails and rolls back.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: How do you avoid the SOQL limit in triggers?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Collect Ids in a set, run one query outside the loop and store the results in a map.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: How do you check how many queries your code used?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use Limits.getQueries() and compare it with Limits.getLimitQueries().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: What is the heap size limit?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6 MB for synchronous Apex and 12 MB for asynchronous Apex.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How many records can SOQL return in one transaction?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">50,000 records across all queries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: Why test triggers with 200 records?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because Data Loader and the API send up to 200 records to a trigger at once. So that is the real-world worst case.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Apex Governor Limits<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: How does asynchronous Apex help with limits?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It runs in a separate transaction with higher limits for queries, CPU and heap.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: What usually causes CPU time limit errors?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nested loops over large lists, complex calculations and too much automation on one save.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: How do you reduce heap usage?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use SOQL for loops, select only needed fields and clear large collections when you are done.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: Do managed packages share your limits?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Certified managed packages get their own limits for many resources, but some limits, such as CPU time, are shared across the transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: What is the callout limit?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">100 callouts per transaction, with a total timeout of 120 seconds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: Where can you see limit usage after a transaction?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the debug log, in the limit usage summary at the end of the transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How would you process 1 million records?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use Batch Apex, which splits the work into many small transactions, each with its own limits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/apex_gov_limits.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Execution Governors and Limits (Apex Developer Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_limits.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Limits Class (Apex Reference Guide)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apex Governor Limits cap queries, DML, CPU, heap and more per transaction.<\/li>\n\n<li>The key numbers are 100 queries, 150 DML statements and 10,000 DML rows.<\/li>\n\n<li>A LimitException cannot be caught and rolls back everything.<\/li>\n\n<li>Query once, use maps and run one DML per list.<\/li>\n\n<li>Use async Apex and Batch Apex for heavy work.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Triggers are where limits matter most. Next, read our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-trigger-basics-context-variables\/\">Apex Trigger Basics and context variables<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apex Governor Limits are the rules that cap how much work one piece of Apex code can do in a single transaction. They limit&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1516,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[8,96],"tags":[98,109,26,91,7,97],"swapz_series":[],"class_list":["post-1519","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","category-salesforce-developer","tag-apex","tag-governor-limits","tag-intermediate","tag-interview-questions","tag-salesforce","tag-salesforce-developer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apex Governor Limits Explained with Examples<\/title>\n<meta name=\"description\" content=\"Apex Governor Limits explained simply: SOQL, DML, CPU, heap and callout limits, the Limits class, sync vs async values and 21 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apex Governor Limits Explained with Examples\" \/>\n<meta property=\"og:description\" content=\"Apex Governor Limits explained simply: SOQL, DML, CPU, heap and callout limits, the Limits class, sync vs async values and 21 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-06T05:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\"},\"headline\":\"Apex Governor Limits Explained with Real Examples\",\"datePublished\":\"2026-09-06T05:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/\"},\"wordCount\":1641,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-governor-limits-explained-featured.png\",\"keywords\":[\"Apex\",\"Governor Limits\",\"Intermediate\",\"Interview Questions\",\"Salesforce\",\"Salesforce Developer\"],\"articleSection\":[\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/\",\"name\":\"Apex Governor Limits Explained with Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-governor-limits-explained-featured.png\",\"datePublished\":\"2026-09-06T05:30:00+00:00\",\"description\":\"Apex Governor Limits explained simply: SOQL, DML, CPU, heap and callout limits, the Limits class, sync vs async values and 21 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-governor-limits-explained-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-governor-limits-explained-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Apex Governor Limits featured image: title card with an Apex code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-governor-limits-explained\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apex Governor Limits Explained with Real Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apex Governor Limits Explained with Examples","description":"Apex Governor Limits explained simply: SOQL, DML, CPU, heap and callout limits, the Limits class, sync vs async values and 21 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/","og_locale":"en_US","og_type":"article","og_title":"Apex Governor Limits Explained with Examples","og_description":"Apex Governor Limits explained simply: SOQL, DML, CPU, heap and callout limits, the Limits class, sync vs async values and 21 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-06T05:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a"},"headline":"Apex Governor Limits Explained with Real Examples","datePublished":"2026-09-06T05:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/"},"wordCount":1641,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-featured.png","keywords":["Apex","Governor Limits","Intermediate","Interview Questions","Salesforce","Salesforce Developer"],"articleSection":["Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/","url":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/","name":"Apex Governor Limits Explained with Examples","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-featured.png","datePublished":"2026-09-06T05:30:00+00:00","description":"Apex Governor Limits explained simply: SOQL, DML, CPU, heap and callout limits, the Limits class, sync vs async values and 21 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-governor-limits-explained-featured.png","width":2400,"height":1260,"caption":"Apex Governor Limits featured image: title card with an Apex code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/apex-governor-limits-explained\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apex Governor Limits Explained with Real Examples"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1519"}],"version-history":[{"count":0,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1519\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1516"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1519"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1519"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1519"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}