function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vigneshwaran LoganathanVigneshwaran Loganathan 

Need help on following

I need clarification on below things which are confusion lot,

1) How many Queries we can do in Trigger? (??)
2) How many Queries we can do in a Apex Class? (150??)
3) How many DMLs we can do in Trigger for an instance? (??)
4) How many DML we can do in class for an instance? (50k??)
5) how many records will be retrieved in a single query in Apex class?
6) how many records will be retrieved in a single query in Trigger?

** In trigger we can do 100soql per cycle. (What does it mean?)

if there is a query like 
SELECT id,name from Account where status='Active'; // consider if there are 7000 active records
will it retrieve all the 7000 records on next to query line?

I have seen somewhere that we can do 20 DML in Trigger for an Instance, another site its 150.. what is true?

Correct me if some questions are wrong, it really confusing a lot :))

Thanks folks.
Best Answer chosen by Vigneshwaran Loganathan
Amit Chaudhary 8Amit Chaudhary 8

1) How many Queries we can do in Trigger? (??)
Amit:- 100 SOQL in one context.

2) How many Queries we can do in a Apex Class? (150??)
Amit:- 100 SOQL in one context. Limit is same of Trigger and Apex class. Only difference in Batch job that is 200.

3) How many DMLs we can do in Trigger for an instance? (??)
Amit:- 10,000 in one context

4) How many DML we can do in class for an instance? (50k??)
Amit:- 10,000 in one context

5) how many records will be retrieved in a single query in Apex class?
Amit:- 50,000 in one context


6) how many records will be retrieved in a single query in Trigger?
Amit:- 50,000 in one context


In trigger we can do 100soql per cycle. (What does it mean?)
Means if trigger will execute one time it may process one or 200 record at a time. means one process(one context)

User-added image

Please check all below link to check salesforce goverment limit
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm
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 2,000

Please let us know if this will help you

Thanks,
Amit Chaudhary
 

All Answers

Amit Chaudhary 8Amit Chaudhary 8

1) How many Queries we can do in Trigger? (??)
Amit:- 100 SOQL in one context.

2) How many Queries we can do in a Apex Class? (150??)
Amit:- 100 SOQL in one context. Limit is same of Trigger and Apex class. Only difference in Batch job that is 200.

3) How many DMLs we can do in Trigger for an instance? (??)
Amit:- 10,000 in one context

4) How many DML we can do in class for an instance? (50k??)
Amit:- 10,000 in one context

5) how many records will be retrieved in a single query in Apex class?
Amit:- 10,000 in one context


6) how many records will be retrieved in a single query in Trigger?
Amit:- 10,000 in one context


In trigger we can do 100soql per cycle. (What does it mean?)
Means if trigger will execute one time it may process one or 200 record at a time. means one process(one context)

User-added image

Please check all below link to check salesforce goverment limit
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

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 2,000

Please let us know if this will help you

Thanks,
Amit Chaudhary
Vigneshwaran LoganathanVigneshwaran Loganathan
Hi Amit,
Thanks for the reply.

how many records will be retrieved in a single query in Apex class?
Amit:- 10,000 in one context

Total number of records retrieved by SOQL queries 50,000

what is the different between these two?
Amit Chaudhary 8Amit Chaudhary 8

1) How many Queries we can do in Trigger? (??)
Amit:- 100 SOQL in one context.

2) How many Queries we can do in a Apex Class? (150??)
Amit:- 100 SOQL in one context. Limit is same of Trigger and Apex class. Only difference in Batch job that is 200.

3) How many DMLs we can do in Trigger for an instance? (??)
Amit:- 10,000 in one context

4) How many DML we can do in class for an instance? (50k??)
Amit:- 10,000 in one context

5) how many records will be retrieved in a single query in Apex class?
Amit:- 50,000 in one context


6) how many records will be retrieved in a single query in Trigger?
Amit:- 50,000 in one context


In trigger we can do 100soql per cycle. (What does it mean?)
Means if trigger will execute one time it may process one or 200 record at a time. means one process(one context)

User-added image

Please check all below link to check salesforce goverment limit
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm
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 2,000

Please let us know if this will help you

Thanks,
Amit Chaudhary
 
This was selected as the best answer
Vigneshwaran LoganathanVigneshwaran Loganathan
Thanks Amit :)