Re: You should have been sacked
And even when not, I've had to optimize systems that others had written.
A financial reporting system that took over 4 hours to pack up the data for transmission to HQ. 2 days work on that system got it down to under 20 minutes. Just a few simple changes. That saved 4 hours times 5 reporting programs, times 12 months, times over 260 reporting sites. Those 2 days re-programming and testing saved the company over 62,000 hours lost productivity a year.
Another time, the customer had already invested in 4 servers and a load-balancer for their commercial webiste, but it still keeld over and died, when more than 25 users per server tried to load a page. The programmers were good at web coding, but hadn't a clue about optimization. They had just thrown new indexes at the database to speed up loading the menu structure, but it hadn't helped. It still took over a minute to load the menu under load.
A quick run through the code, re-oder the WHERE clause so the database could process it optimally - as opposed to the programmers being able to read it in "from front-to-back" order (I changed it from human understanding drop-through to database starting with the shortest exclusion and working outwards). A few changes to the deeply nested surrounding IF statements in the PHP code and hey presto, the query sank from over 1 minute to execute to under 500 milliseconds. The page load time dropped to under 3 seconds.
Sometimes a company is more than willing to pay for optimization. Spending a few days of developer time to save 7 man years of accountants time per year, for example, or customer satisfaction at not having to wait for pages to load, is peanuts in comparisson to what the company will have to give out otherwise or could lose due to poor customer experience.