| mysql stops processing suddenly, no error [message #1759] |
Fri, 07 September 2007 14:50  |
bluem Messages: 15 Registered: November 2006 |
Junior Member |
|
|
I have a PHP script that queries the database for a fairly large number of rows, using mysql_query(), then runs through those rows and stores them in PHP array using mysql_fetch_array() for each row. The script does nothing else during the loop, just data storage in an array. For example, on 15,000 rows, it will loop for about 8000 rows, then all processing stops. The server returns a blank page, no time out warning, nothing, just says "Done" in the status bar at bottom of browser.
After loading the array, the script uses in the information for further processing ... but of course the script doesn't get to that point.
However, if I instead use mysql_fetch_array() to get one row, then do some PHP processing on that row, THEN get the next row, etc, instead of immediately storing everything into an array first, then it works.
What could be causing the termination? Is it calling mysql too fast during the loop? Is there a mysql memory problem? I doubt it's a PHP limitation on array size. It's also not a PHP timeout issue; it quits long before that (I've checked).
I'm using XAMPP on Windows, by the way; however, I've seen a similar thing on my live linux server when doing large queries, where the server returns a blank "Done" page.
Thanks for any advice. I have to say this forum is a life-saver.
|
|
|
|
| Re: mysql stops processing suddenly, no error [message #1798 is a reply to message #1759 ] |
Tue, 11 September 2007 15:24   |
|
Why do you think it's mysql problem?
I think it could be:
1) Time limit - set_time_limit(0) to solve.
2) Memory limit in php - change memory_limit option in your php.ini.
Alexey Kovyrin, MySQL Performance Expert
MySQL Performance Blog
MySQL Consulting
|
|
|
|
| Re: mysql stops processing suddenly, no error [message #1874 is a reply to message #1759 ] |
Fri, 14 September 2007 17:46  |
bluem Messages: 15 Registered: November 2006 |
Junior Member |
|
|
Thank you very much ... memory_limit was it!
I did a test using memory_get_usage() and sure enough, the script terminated when the PHP array got too big (reached memory_limit).
This was on Windows, and php.ini is accessible so I set memory_limit there just fine.
On my live server, memory_limit is *not* configured. Can't see it in phpinfo() and memory_get_usage() fails. Does PHP have a default memory limit, I wonder?
|
|
|