Theoretical question please.
When writing a batch class and using a start method that returns a QueryLocator (or Iterable for that matter), we can potentially include child accounts in the query. For example: SELECT Id, (Select Id From Contact) FROM Account
.
Now let's say the batch is being executed with a scope size of 200. Which records would scope per this 200 parameter? Is it 200 accounts? Or is it counting retrieved rows - each account as 1, and then as many contacts as it has? And if that's the case, what happens if the very first retrieved account has 203 contacts? So 1 account and 199 of its contacts are transferred to the execute method, what happens in the next execution?
Will it remember to pick up those remaining 4 contacts? And how will they be associated to the account from the previous execution, given that by defition we're actually transferring account records and not contact records?
Many thanks!