I am using batch apex to associate a contact to a case. I will need to compare all the contacts in the system to the cases with a 'new' status. first_name__c and last_name__c are fields on the case. I want to go over every contact and see if there is a match between the first name and last name on a contact and a 'new' case's first_name__c and last_name__c. If there is 1 match, associate the contact and case. If there are 0 matches, create a new contact and associate it to the case. If there are multiple matches, do nothing and the case will have a null contact. I am using the query locator to get the contacts, which could be millions.
I need to have all the contacts in one batch, can I increase the batch size to 50,000,000? This seems like really bad practice.
If I pass in a batch size of 200 for example, will batch #1 finish before batch #2 begins? For example, in every execute I query for cases with status = 'new'. In the first batch, the contact on the case will be null. If I find a contact and case match in the first batch, it is assigned to the case and the status is unchanged (still 'new'). Will this assignment be reflected in the second batch?