Running a batch is needed because people want to see results from the batch in the same day. Now our batch runs every night Are there any issues (for example performance issues) of running a batch during work time (9am - 5pm) 3 times a day? We have very small number of users and we don't have any performance issues yet

1 Answer 1


There are three main considerations. First, does the batch run so long that the next would start before the first finishes? Second, does the batch need to consider records modified since the start method's Database.getQueryLocator method is called? Third, will the batch perform DML operations on records that users might be editing at that moment? As long as all three questions can be answered with "no" (or "I don't care"), then there's no problem at all. Otherwise, you'd need to consider what would happen in those cases.

Realistically, only you can answer those questions. In most cases, running the batch a few times a day on a limited amount of data is perfectly acceptable. For example, if the nightly batch is calculating values for 24 hours, the three-times-a-day batch might only need to calculate values for 4-5 business hours, which means each batch could run faster, since it'd have less data.

The downside, however, would be the DML scenario; if a user loads a record before the batch processes the record, and tries to save after the batch performs a DML operation on the record, could cause the user to lose data ("this record has been edited by another user") or possibly cause the batch's data to be overwritten (e.g. in the context of a custom Lightning Component). Again, only you can assess the risk here.

Consider testing this in a Sandbox with a group of users for a day or two and see if they report anything. If not, it's probably safe to do in production. Or, if you feel the risk is insignificant enough, as you've stated you have a small group of users, it's probably okay to have the batch class run during business hours. Just consider the potential problems above and make a risk assessment. Some consultants, free-lancers, and/or consulting firms would be happy to make a more personal assessment with you if you're not sure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .