It's not that I'm against highly paid consultants. Call me old-fashion, but I really do believe that leveraging a strategic partnership with a proactive service organization can actually synergize and streamline mission-critical objectives. But no less, I do love sharing stories like this from Greg ...
After starting a new job as a Senior Developer, I was given the task to track down a problem in one of the company's web applications. Users had been reporting for six to seven months that a particular web page had been taking as long as eight minutes to load.
After running the application and experiencing the slowness myself, I began running tools on the code and on the database while stepping through the application. Using SQL Profiler, I quickly saw what was causing the problem. During the load of a single web page, I determined that the following was occurring:
- SQL Server was issuing 456,302 locks;
- COM+ was starting 299 transactions;
- 1,150 select/update/insert statements were sent to the database.
Once the page finally loaded, there were ten items listed in the grid, but it somehow took over 1,100 SQL statements to retrieve them.
I discussed my findings, as well as my astonishment, with my co-workers--there are seven other developers at the company. Everyone was surprised. I spent the next two weeks fixing everything, and I was able to return the same data using only a single stored procedure that contained five select statements. After I fixed (re-wrote) the page, it loads in less than a second.
The sad part is that the other developers who were here before I arrived had never been able to get to the bottom of the problem. They all thought the database tables needed to be indexed better or that general SQL Server tuning *should* fix the problem.
The really, really sad part is that the company paid about $500,000 to a "top-tier" consulting firm to write the original application. They, too, suggested that tuning SQL Server should fix the problem.
I have been fixing bugs and adding functionality to the code for over a month now, and I am shocked every single day at how poorly the application was written.