Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timeout on Large MySQL Query

I have this code:

$theQuery = mysql_query("SELECT phrase, date from wordList WHERE group='nouns'");
while($getWords=mysql_fetch_array($theQuery)) {
 echo "$getWords[phrase] created on $getWords[date]<br>";
}

The query has 75,000 results, and every time I run the code I get an error.

like image 569
Bob Stewart Avatar asked Nov 24 '25 00:11

Bob Stewart


1 Answers

Several issues could be at play here, all of which are due to settings in your php.ini. Your script could be timing out since PHP defaults to a 30 second maximum for script execution. The other reason (and just as likely) is that you're hitting a script memory limit which is defaulted to 8MB per script execution.

Open php.ini and search for "Resource Limits" and make the appropriate modifications.

like image 157
Jarrod Nettles Avatar answered Nov 25 '25 14:11

Jarrod Nettles