mrherman Posted September 16, 2010 Share Posted September 16, 2010 Hello, everyone -- I'm wondering why this is happening... I have a MySQL table of 1200 rows of students, in grades 9-12. They took a test, with differentiated questions for each grade level. Only one table is used, no joins, real simple. My PHP scoring program works ok. With one school of 300 test takers, the program requires about 1.5 minutes to score. When I add in 3 additional schools, it doesn't take 4 x 1.5 minutes to score -- it takes about 30 minutes! No school is "different" from another school. As it scores, it does the first several hundred rows quickly. But then it starts to slow down and then crawls, so that by the end of the scoring routine, it is scoring only 1 record per 2 - 4 seconds, it seems. Just looking for some insight on what is happening. Is it a memory-usage issue (computer has 6GB, running Win7). Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213570-why-does-the-database-slow-down/ Share on other sites More sharing options...
Mchl Posted September 16, 2010 Share Posted September 16, 2010 Several possible reasons 1. Inefficient database design - quite possible in your case (one table???) 2. Inefficient queries - not using indexes 3. Inefficient application logic (multiple nested loops for example) Quote Link to comment https://forums.phpfreaks.com/topic/213570-why-does-the-database-slow-down/#findComment-1111656 Share on other sites More sharing options...
PFMaBiSmAd Posted September 16, 2010 Share Posted September 16, 2010 My PHP scoring program works ok. With one school of 300 test takers, the program requires about 1.5 minutes to score. That's not working ok. It should take at most a few seconds to a few 10's of seconds. It sounds like you have php code retrieving and looping through all the rows from one or more tables, with queries being executed inside of loops... inside of loops. You also probably have memory management and table indexing issues. It would take seeing the code responsible for the symptoms, an example of the data being processed, a statement of how much total data is being processed, and the definition of the tables involved to directly help. Quote Link to comment https://forums.phpfreaks.com/topic/213570-why-does-the-database-slow-down/#findComment-1111660 Share on other sites More sharing options...
mrherman Posted September 16, 2010 Author Share Posted September 16, 2010 Yes, you are right...There are lots of loops-inside-of-loops and queries within loops. This is what I was was wondering was the culprit, especially since the first few hundred rows went relatively quickly. Thanks for the comments. Quote Link to comment https://forums.phpfreaks.com/topic/213570-why-does-the-database-slow-down/#findComment-1111666 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.