Salesforce Limits: A Quick Overview

Salesforce, being a multi-tenant platform, imposes various limits and restrictions to ensure that all its users have optimal performance. This tutorial will provide you with a comprehensive overview of Salesforce limits, with examples to help you understand their implications.

Salesforce limits refer to the restrictions and boundaries set by Salesforce on various features and functionalities. They’re meant to prevent the overconsumption of resources, potential platform abuse, and maintain overall system performance.


1. Overview of Salesforce Limits

These limits can be broadly classified into the following categories:

  • Governor Limits: Runtime limits enforced by the Apex runtime engine.
  • API Limits: Restrictions on the number of API calls.
  • Storage Limits: The amount of data and file storage provided.
  • UI and Customization Limits: Restrictions in UI customization and user experience.

2. Governor Limits

These limits ensure that no single organization hogs shared resources.

a) Per-Transaction Apex Limits

Limit Type Limit Value Example
Total number of SOQL queries 100 If you try to perform 101 SOQL queries in a single transaction, it will throw a limit exception.
Total records retrieved by SOQL 50,000 Retrieving more than 50,000 records will result in an exception.
Total number of SOSL queries 20 Only 20 SOSL queries can be executed in a single transaction.
Total records retrieved by DML 10,000 Any DML operation affecting more than 10,000 records will fail.
Total number of DML statements 150 You can have at most 150 separate DML operations (like insert, update, delete).

b) Size-Specific Apex Limits

Limit Type Limit Value Example
Maximum heap size 6MB (sync) / 12MB (async) Heap size refers to the runtime memory for your variables, objects, etc.
Maximum SOQL query runtime 120 seconds Queries running longer than this will be terminated.

c) Miscellaneous Apex Limits

Limit Type Limit Value Example
Maximum CPU time on the Salesforce servers 10,000 ms (sync) / 60,000 ms (async) CPU time for processing, excluding API callouts.

Key Tip: Always use bulkified code to avoid hitting these limits, especially in triggers.


3. API Limits

These are set on a 24-hour rolling window.

API Type Professional Edition Enterprise Edition Unlimited & Performance Edition
SOAP, REST, etc. 5,000 15,000 100,000

Example: If you’re using the Enterprise Edition and made 10,000 API calls by 3 PM, you can only make another 5,000 until 3 PM the next day.


4. Storage Limits

a) Data Storage

Edition Base Storage Additional Storage per License
Professional 20 GB Not applicable
Enterprise, Performance, Unlimited 10 GB 20 MB per user

b) File Storage

All editions receive 10 GB of file storage plus 2 GB multiplied by the number of user licenses.

Example: An Enterprise Edition org with 50 users gets 10 GB + (50 users * 2 GB/user) = 110 GB.


5. UI and Customization Limits

a) Objects, Fields, and Relationships

Limit Type Professional Enterprise Unlimited & Performance
Custom Objects 200 2,500 3,000
Custom Fields (Standard Objects) 500 800 1,200
Custom Fields (Custom Objects) 800 500 800

b) Tabs and Apps

Limit Type Professional Enterprise Unlimited & Performance
Custom Apps 5 10 100
Custom Tabs 10 25 100

Best Practices:

  • Bulkify Code: Ensure code processes multiple records simultaneously to avoid hitting transaction limits.
    For example:

    for(Account acc : [SELECT Id FROM Account]) {
      // Wrong: This will quickly exhaust the SOQL limit in large orgs
    }
    
    List<Account> accounts = [SELECT Id FROM Account];
    for(Account acc : accounts) {
      // Better: One SOQL query is used
    }
    

     

  • Optimize Queries: Use selective SOQL queries to avoid retrieving unnecessary data.
  • Monitor & Alert: Set up notifications to inform you when nearing certain limits.
  • Archival Strategy: Implement data archival processes to manage storage limits effectively.

 

Conclusion: Salesforce limits exist to ensure fair use across all users on their multi-tenant platform. Understanding and planning around these limits is crucial for effective development and administration within Salesforce. Regularly consulting Salesforce’s official documentation will help stay updated on any changes to these limits.

Leave a Comment