iori
iori

Reputation: 3506

What is the max of maximum_execution_time in PHP?

I have about 200,000 rows that need to add to the database.

I have set my maximum_excution_time = 4000, I still get this error.

enter image description here

What is max of maximum_execution_time in PHP ?

I want to take off this restriction completely and set it to unlimited if possible.

Upvotes: 2

Views: 272

Answers (1)

Alana Storm
Alana Storm

Reputation: 166166

I know using a value of 0 in set_time_limit will tell PHP to not timeout a script/program before it's finished running. I'm pretty sure setting the same value in maximum_excution_time will have the same effect.

That said: Some hosting companies have other systems running to look for long running processes of any sort (PHP, Ruby, Perl, random programs, etc.) and kill them if they're running too long. There's nothing you can do to stop these system from killing your process (other than moving to a different host)

Also, certain versions of PHP have a number of small memory leaks/inefficient garbage collection that can start to eat up memory when using in long running processes. You may hit PHP memory limit with this, or you may eat up the amount of memory available to your virtual machine.

If you run into these challenges, the usual approach is to batch process the rows in some way.

Hope that helps, and good luck!

Update: Re batch processing -- if you find you're stuck on a system that can only insert around 10,000 rows at a time, rather than write a program to insert all 200,000 rows at once, you write a program/system that will insert, say, 9,000 and then stop. And then you run it again and it inserts the next 9,000. And then next 9,000 until you're complete. How you do this will depend on where you're getting your data from. If you're pulling this data from flat files it can be as simple as splitting the flat files into multiple files. If your'e pulling from another database table it can be as simple as writing a program to pull out arrays of IDs in groups of 9,000 and have your main program select those 9,000 rows. Messaging queue systems are another popular approach for this sort of task.

Upvotes: 4

Related Questions