Take a step back and think!

Categories: Troubleshoot



On the weekend, I reviewed the tree traverse function that I did for an ongoing freelance project. Each node have 3 child. I tried to insert 200 records and it took quite a long time to insert the records into the database. 23 seconds.

thinking cat

I am quite sure of the code that I didn’t bother to look at it first and search for other means of alternative on improving the insertion. I googled around for MySQL performance and found a few posts on MySQL Performance Blog. Merge Tables. I need to find out more about this storage engine. I opened up High Performance MySQL, and read up on it.

After an hour reading the book, thinking of ways to implement it and including the constraints of current web host, I thought to myself, this is too hard and complicated, not that I can’t solve hard problems. Haha! I took a few steps back, and try to do something else like watching a funny anime, Gintama. Sometimes taking a break unravel the mind from all the messy thinking being done and makes it easier to think clearly.

Later on I try to think about it again and found out that I’m doing a depth-first search. Which is why it is taking such a long time. I rewrote it to use breadth-first search and it solved my problem for the mean time. I still have to test if it can handle 6165 data insertion.

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress with GimpStyle Theme design by Horacio Bella.
Entries and comments feeds. Valid XHTML and CSS.