[SalesForce] Fetching records with SOQL in batch apex

Some SOQL starts batch job with 'where' clause. This batch job is running several minutes/hours and some records from original set change state and don't satisfy original SOQL 'where' conditions. How does the job behave in such scenario? Does original result set cached or system run soql each time to get 200 records so changed record will be excluded and is not processed. Thanks for ideas!

Best Answer

The original result set is cached and thus your records have the original state... As explained here http://blogs.developerforce.com/engineering/2013/02/force-com-batch-apex-and-large-data-volumes.html

1) The start method of a batch Apex class collects the records or objects that will be processed.
2) The execute method picks up batches of these records and does the bulk of the processing.