Salesforce is considered as a Multitenant architecture, where all users share the same infrastructure and the same version of the Salesforce platform. In comparing to their single-tenant platforms such as CSE(client-server enterprise) applications or mail servers, multi-tenant architectures will release upgrades automatically and simultaneously for all users. Therefore, there will be no worrying about maintaining their hardware or software, and we can make sure that their applications have the latest patches installed.
This is to ensure we follow Salesforce standards. As Salesforce works in shared server format, means multitenant architecture, Salesforce wants the resources should not be over utilised by any client. Your code should execute within the execution limits which are predefined. If the governor limit exceeds, then the run-time error is thrown. By following the below mentioned best practices in our code, we can avoid these limit errors.
Check Out Salesforce Tutorials
Description | Synchronous Limit | Asynchronous Limit |
Number of queries issued by SOQL | 100 | 200 |
Total number of records retrieved by SOQL queries | 50,000 | |
Total number of records retrieved by Database.getQueryLocator | 10,000 | |
Total number of SOSL queries issued | 20 | |
Total number of records retrieved by a single SOSL query | 2000 | |
Total number of DML statements issued | 150 | |
Total number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin | 10,000 | |
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements | 16 | |
Total number of callouts (HTTP requests or Web services calls) in a transaction | 100 | |
Maximum cumulative timeout for all callouts (HTTP requests or Web services calls) in a transaction | 120 seconds | |
Maximum number of methods with the future annotation allowed per Apex invocation | 50 | |
Maximum number of Apex jobs added to the queue with System.enqueueJob | 50 | |
Total number of send email methods allowed | 10 | |
Total heap size | 6MB | 12MB |
CPU time on the Salesforce servers | 10,000 milliseconds | 60,000 milliseconds |
Maximum execution time for each Apex transaction | 10 minutes | |
Maximum number of push notification method calls allowed per Apex transaction | 10 | |
Maximum number of push notifications that can be sent in each push notification method call | 2,000 |
Bulkification means, the code must work on one record as well as on many records. It means the code needs to be written in such a way that, if one record causes the DML or 100’s of records causes the DML, the code should handle all the records. Just by writing code suitable for multiple records is not going to give a proper solution. We need to focus and make sure that our code is not breaking the limits, i.e., Governor limits.
Governor limits + Bulkification = Ideal way of coding in Salesforce.
Frequently Asked Salesforce Interview Questions & Answers
@isTest // Called as Annotation Public class JeanDiscountClassTest( //we are calling MyTestFunction1(){} -------> 30 DML //we are calling MyTestFunction2(){} -------> 40 DML Static testmethod void MyTestFunction3(){ ======some other code====== ======some other code====== ======some other code====== Test.StartTest(); //create a new record data Levis__c j = new Levis__c(); j.Name = ‘Louis’; j.Price__c = 200; //insert jean Insert j; //trigger will come to picture //retrive the new jean Levis__c j2 = new Levis__c (); //same like, list<> MyList = New List<string>(); j2=[SELECT Price__c FROM Levis__c WHERE id=j.id]; //test that the trigger correctly updated the price system.assertEquals(900, j2.Price__c); Test.StopTest(); } ======some other code====== ======some other code====== ======some other code====== //we are calling MyTestFunction4(){} ---------> 60 DML //we are calling MyTestFunction5(){} ---------> 10 DML )
In the next topic, we will discuss in detail about “Bulkification in Salesforce”. Keep following us for more info on Salesforce Development / Programming.
Mindmajix offers different Salesforce certification training according to your desire with hands-on experience on Salesforce concepts
Free Demo for Corporate & Online Trainings.