Rusty3 Posted November 2, 2009 Share Posted November 2, 2009 I get 500 over and over from server before getting a successful one. Db is not that big. Any clue greatly appreciated. $query="SELECT * FROM table1 WHERE condition"; $results=mysql_query($query); while($row = mysql_fetch_array($results, MYSQL_ASSOC)) { $query2="SELECT * FROM table2 WHERE condition2"; $results2=mysql_query($query2); Quote Link to comment https://forums.phpfreaks.com/topic/179910-why-is-this-slow-and-cpu-intensive-as-hell/ Share on other sites More sharing options...
corbin Posted November 2, 2009 Share Posted November 2, 2009 Errr.... We'll need more code to know for sure, and EXPLAIN results on any queries involved. Can the two queries be combined using a JOIN? Quote Link to comment https://forums.phpfreaks.com/topic/179910-why-is-this-slow-and-cpu-intensive-as-hell/#findComment-949092 Share on other sites More sharing options...
Rusty3 Posted November 2, 2009 Author Share Posted November 2, 2009 Errr.... We'll need more code to know for sure, and EXPLAIN results on any queries involved. Can the two queries be combined using a JOIN? Thanks corbin. So there's nothing wrong with the code... I can't because one depends on the results of the first one. When run alone both are very fast. When together, I get a 500! Quote Link to comment https://forums.phpfreaks.com/topic/179910-why-is-this-slow-and-cpu-intensive-as-hell/#findComment-949156 Share on other sites More sharing options...
dreamwest Posted November 2, 2009 Share Posted November 2, 2009 If table1 doesnt have any BLOB fields, ill bet you any money it in the looping queries $query2="SELECT * FROM table2 WHERE condition2"; $results2=mysql_query($query2); Do you have to select all from table2? Can you select only the fields you want eg. SELECT name,description FROM table2? And does the table have any BLOB or large fields in it? Quote Link to comment https://forums.phpfreaks.com/topic/179910-why-is-this-slow-and-cpu-intensive-as-hell/#findComment-949173 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.