This process not only takes 45 minutes but also a lot of memory.
Use the offset and limit to retrieve chunks of data and process them. After that call the community commons 'EndTransaction'. This will save all data to the database and release the memory. Increase the offset and start again until the retrieve results in an empty list.
Limit can be something between 1000-5000.
This will still take an amount of time but it will consume far less memory and if its fails at a certain point all data passing 'EndTransaction' is stored in database. If you do this all in one transaction it won't do anything effectively.
See also the documentation here: https://world.mendix.com/display/howto40/Retrieve+and+manipulate+batches+of+objects
Regards,
Ronald
[EDIT]
Documentation needs an update. The one that comes close is now this one: https://docs.mendix.com/howto7/monitoring-troubleshooting/detect-and-resolve-performance-issues#batches
But indeed the documentation needs to be improved again. I pitty they did remove the old page.