I need to schedule anually a batch, on January 1st every year. This batch has to process all accounts to update a checkbox field. I'm trying to decide what is less expensive for the platform, so I can avoid hitting limits. My options:
- One batch. The query spans to one lookup relationship, bringing only one of those child records, depending on a specific check on them. Iterate the results, check the corresponding conditions and update the checkbox and bulk update the whole batch.
- Two batches. One for the records whose checkbox will be updated to true. Another for the ones which will get it updated to false. No need to check conditions because the queries already filtered the records appropriately. Then just iterate them and update the checkbox accordingly.
Which one is less expensive? Or is this irrelevant? If it's irrelevant, are there other factors that have to be taken into consideration? My concern has to do with the quantity of accounts.