My idea is that you go to check in batches, and then export in batches,
similar to paging, every 1000 or more as a batch
By batch to perform, and then make a progress bar, according to how many batches as the number of progress for the export
This should be a lot better
It is also possible to make a caching mechanism to store the next time you get the data directly from the cache.
There could also be a caching mechanism to store batches, so that the next time you get data, you get it directly from the cache
.