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
SumitkSumitk 

Batch apex vs triggers

I need to create monthly report of my data for my each and every user.  So there could be lots of records if there are lots of user. These records are normally created by a batch process running weekly as an example that runs for hours to calculate all the monthly utilization records for each user.
.
I do not want to compromise with performance of my application especially on peak hours. 

So should I continue with the batch process or do the same in real time using triggers? Or is there any other better way to achieve the same? 
AnudeepAnudeep (Salesforce Developers) 
If you are anticipating processing more number of records, you should proceed with Batch Apex. Also, the governor limits of a batch apex are different. Some major differences are

Trigger:-
1) Processes synchronously
2) You can do 100 SOQL per cycle
3) Triggers process 200 in one context

Batch job:-
1) Processes Asynchronously
2) 200 SOQL per cycle
3) Depend on batch job size.

The trigger will invoke when you will do any DML on a particular Object. However, with batch apex, you can execute when you want or you can schedule with a scheduled job 

Keep in mind though. Batch Apex runs asynchronously, which can make it hard to troubleshoot without some coded debugging, logging, and persistent stateful reporting. It also means that it's queued to run, which may cause delays in starting.

Also, there's a limit of 5 batches in play at any time, which makes it tricky to start batches from triggers unless you are checking limits.

https://trailhead.salesforce.com/en/content/learn/modules/asynchronous_apex/async_apex_batch

if you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You

Anudeep