Beauty’s where you find it
1 May
I recently finished my first CakePHP application. Not only was the application the largest I have ever written, but I had never worked with CakePHP before. So, needless to say, not only did I have to overcome a learning curve, but I had to deal with all that comes with writing a large application. Today I was contacted by the project manager regarding a bug which had surfaced in the application. In my quest to squash the bug I discovered a script which was causing a section of the administrator to act very sluggish. In examining exactly what was going on, I realized that there were 200+ calls being made to the database. Ok. That’s bad. I’d like to clarify that I was the one who wrote the original offending code. In about 2 minutes of work I was able to bring the query count down to 2, and reduce the page response time considerably.
On the one hand it hurts my ego to know that I could write something so bad. On the other hand I can kind of forgive myself, as the timeline was tight, the application had so many moving parts, and the learning curve was present. Either way, it felt really good to see such a performance improvement with such minimal effort. Part of my problem is that early in the application I wasn’t paying attention to Cake’s binding of associations. Today was a good lesson in why I should always pay attention to bindings in CakePHP.
Leave a reply