Home » Performance » MySQL » mysql stops processing suddenly, no error
mysql stops processing suddenly, no error [message #1759] Fri, 07 September 2007 14:50 Go to next message
bluem  is currently offline 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 #1794 is a reply to message #1759 ] Tue, 11 September 2007 12:42 Go to previous messageGo to next message
bluem  is currently offline bluem
Messages: 15
Registered: November 2006
Junior Member
Hmmm ... no replies. Was my question not clear, I wonder?

Has anyone else experienced mysql just stopping when using PHP's mysql_fetch_array() on lots of rows?
Re: mysql stops processing suddenly, no error [message #1798 is a reply to message #1759 ] Tue, 11 September 2007 15:24 Go to previous messageGo to next message
scoundrel  is currently offline scoundrel
Messages: 58
Registered: August 2006
Location: Toronto, ON, Canada
Member

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 #1799 is a reply to message #1759 ] Tue, 11 September 2007 19:06 Go to previous messageGo to next message
allworknoplay  is currently offline allworknoplay
Messages: 58
Registered: September 2007
Location: New York
Member
How long does it take for your program to loop through 15K rows?

You said it doesn't take too long but we need specifics...
Re: mysql stops processing suddenly, no error [message #1874 is a reply to message #1759 ] Fri, 14 September 2007 17:46 Go to previous message
bluem  is currently offline 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?
Previous Topic:Can't change key_buffer_size
Next Topic:MERGE and indexes
Goto Forum:
  


Current Time: Fri Jul 10 02:41:25 EDT 2009

Total time taken to generate the page: 0.01963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.