Refactored code to address out of memory Heap Space error to read
records in chunks from MySQL