Issue #3543889: Fix allowed memory exhausted by introducing batch processing on the function for exporting data from DB.
Closes #3543889