One-Time Script TimeOut for Large Data

It is just a mistake to run reporting style task on a production site. you can live with it for a “small” site, but the bigger the site is, you will run against the limitation of webserver architecture, language architecture, and framework architecture, which neither of them was designed to handle CPU and memory stressful tasks.

One obvious way to break out of the limitations, is to download the DB and run whatever you want on a local PC which is most likely much more powerful than your web server.

If for whatever reason it is hard to do, your best bet is probably to integrate the report generation with WP-CLI, and run it from the server’s command line (you do have ssh access, right? 😉 ) this way you avoid the webserver related limitation, but still might be problematic if it uses lots of memory and CPU, so you might need to structure your code smartly, breaking generation into chunks instead of trying to do it in one go.

…. and breaking into chunks can be achieved by using some sort of progressive generation with ajax. Can it be done in your case? depends if you can break the whole operation into mostly independent chunks.