We have a query that takes about 10 minutes to complete but it seems that PHP doesn’t want to wait around for it. If the user does, PHP will respond with the actual query in plain text. No errors or anything like that are reported.
We thought it was an Apache thing, tried to configure it, didn’t work, swapped over to nginx
and it still gets the same result.
I call set_time_limit(0);
at the very beginning of the script.
What is it I’m missing?
EDIT:
I’d like to clarify that PHP isn’t doing any computation. It’s simply waiting for the result of a query from the database and then formatting the result into an Excel file.
2
Answers
Unfortunately php is not built for heavy processing
I also had this problem in some of my code
My suggestion is:
But in general, it is better to entrust heavy processing to another programming language
Like Java,python, ect
You can read more about this on these sites:
https://www.reddit.com/r/PHP/comments/2pyuy0/heavy_data_processing_in_php/
Best way to manage long-running php script?
Try setting "max_execution_time" with
ini_set("max_execution_time", 0); but PHP was not build for this kind of work – try to use different dev language (Python, NodeJS?)
Did you try to make your query more optimized? Or try running it in more steps. Try generating some tables with partial results. Then re-do the query on those?