Welcome Guest, Not a member yet? Register   Sign In
Extremely long execution time
#2

[eluser]stef25[/eluser]
Nested foreach will absolutely cause problems like this. I had the same problem on a site of mine. With 10 rows of test data I didn't notice it but with 300 rows of real data it took 5+ sec to load the page. And that was with only 2 levels of foreach, you have three.

If the first array contains 1000 elements and the second one does too then you have 1000 x 1000 iterations = 1.000.000 loops. Add another 1000 in your third array and you have a billion iterations. Put a counter on it to make sure I'm not wrong.

If you change your code to foreach($kategorije as $k) print_r($k) then I'm sure it will be less than a sec. Since you have no queries, it can not be much else than nested foreaches Smile


Messages In This Thread
Extremely long execution time - by El Forum - 08-30-2010, 05:26 AM
Extremely long execution time - by El Forum - 08-30-2010, 08:11 AM
Extremely long execution time - by El Forum - 08-30-2010, 08:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB