We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
PHP Nested Loop
davidjwest
Posts: 756 Forumite
in Techie Stuff
I've written a fairly simple piece of PHP that includes 3 nested loops (for loops) and it's now extremely slow, taking several minutes to process.
There's nothing very complex going on, total of about 100 MySQL updates in there, is there a known issue with nested loops in PHP, Google doesn't seem to think so.
Anyone got any ideas, I can post the code if you want to look at it.
There's nothing very complex going on, total of about 100 MySQL updates in there, is there a known issue with nested loops in PHP, Google doesn't seem to think so.
Anyone got any ideas, I can post the code if you want to look at it.
:A
0
Comments
-
It doesn't really sound that efficient.
and 100 update statements sounds like a lot ouside of some form of transformation process, which isn't really PHPs job.
Time how long each section takes to execute and see your bottleneck really is. But its almost certainly your SQL code.0 -
The code performs 10,000 MySQL inserts and that takes 2 seconds, it then comes to the 3 nested loops and takes several minutes, including less than 100 MySQL updates.
Code isn't as efficient as it could be but I don't understand why the huge increase in time, maybe there's some other issue.:A0 -
I know very little about this, but let us assume your code does not contain any bug. The kinds of things I would be looking for are
- Wrong order of nesting, making more work
- Hopping across tables and back, not allowingg caching to speed things up
- Unnecessary operations to open and close table and so forth
Hi, we’ve had to remove your signature. If you’re not sure why please read the forum rules or email the forum team if you’re still unsure - MSE ForumTeam0 -
Chances are, to give you help you'll need to cough up some of that code. Personally, I would try here:
http://www.codingforums.com/forumdisplay.php?f=60
This discussion has been closed.
Confirm your email address to Create Threads and Reply
Categories
- All Categories
- 355.1K Banking & Borrowing
- 254.6K Reduce Debt & Boost Income
- 455.8K Spending & Discounts
- 247.9K Work, Benefits & Business
- 604.9K Mortgages, Homes & Bills
- 178.8K Life & Family
- 262.6K Travel & Transport
- 1.5M Hobbies & Leisure
- 16.1K Discuss & Feedback
- 37.7K Read-Only Boards