+ Start a Discussion
mukesh guptamukesh gupta 

SOQL Limit

Hi Expert,

In one class i have two soql:-
Example:- 
public class test(){

     List<Account> acc = [select id, name from Account Limit 40000];
     List<Contact> con = [seldect id, email from Contact Limit 15000];
}

//above queries will return limit excede error or not 

 
Alain CabonAlain Cabon
Hello,

As these limits could change for each release, the easiest way to see all the governor limits is to launch your queries with the anonymous window (Ctrl+E) of the developer console.

List<Account> acc = [select id, name from Account Limit 40];
List<Contact> con = [select id, email from Contact Limit 15];

It is cummulative for each transaction for the number of query rows: 40 + 15 = 55 so 40000 + 15000 > 50000 will fail.


User-added image

 
Raj VakatiRaj Vakati
Adding one more point 

You can try it like this
 
public class test(){

     List<Account> acc = [select id, name ,(seldect id, email from Contactd Limit 15000) from Account Limit 40000];
   
}

 
Ajay K DubediAjay K Dubedi
Hi Mukesh,

As we know there are certain governor limits specified for each Apex transaction.
50,000 records at a time can be retrieved from a SOQL query.
As per your code, you are using two different SOQL queries which are not individually exceeding the
apex governor limit in any case.

So, you will not get any error in your code.
For more details about Salesforce Governors limit do follow the link below:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

Hope this explanation will help you.Mark it as best answer so others get help from this.
Thanks.
Ajay Dubedi