Optimization starts on day one

An experienced team with time to improve the code should use it. Calling known waste premature optimization can leave the thinking unfinished and the technical debt growing.

On this page

I think optimization should start on day one. If an engineer understands the problem, knows a more efficient way to solve it, and has no deadline blocking that work, I want them to do it. Waiting for a customer complaint adds no value to the decision. Neither does putting a known problem into a backlog that already has enough of them. An experienced team should be able to spend time making software efficient before it becomes slow enough to embarrass the company. Calling that work premature can become an easy way to postpone the thinking and leave someone else to collect the technical debt.

The quote deserves a fair reading. In his 1974 paper, Donald Knuth wrote that “premature optimization is the root of all evil”. The surrounding passage warns about spending time on unimportant code and making debugging and maintenance harder. It also argues for taking worthwhile improvements and measuring which code matters, because intuition can be wrong. I agree with that. The part I object to is turning a warning about wasted effort into a rule that efficiency must wait. Early and premature are different claims. The date on a task tells me very little about whether the work makes sense.

Some costs are visible before production

Consider a page that shows books and their authors. A developer fetches ten books, then makes another database query for each author. The Rails guide uses exactly this example. Eleven queries become two when the developer fetches the required authors together. This is the N+1 query problem. With a separate database server, those extra queries mean extra trips between the application and database. Someone could leave the loop alone because the page feels fast with ten test records. An experienced engineer can inspect the queries and remove that unnecessary work while writing the feature. GitLab makes this expectation explicit in its development guidelines. New features should avoid N+1 queries, including cases where a query cache hides the problem. The team can check this before launch. No paying customer needs to suffer first.

Figma made a much larger decision early. In a December 2015 account of its newly announced editor, Evan Wallace described an editor written in C++, compiled to JavaScript through Emscripten, with a custom WebGL renderer. The team controlled memory layout and allocation to help keep editing smooth. They had already built this while public access still involved a waiting list. Rendering performance belonged inside the product they were trying to make. They could not sensibly leave the editing experience for a later performance sprint. This involved substantial engineering and real browser compatibility problems, which Wallace also described. I would never copy that architecture into an ordinary form application. What I take from it is the willingness to understand a known requirement and spend engineering time meeting it from the beginning.

Waiting can make the fix harder

The same decision appears in smaller work. Imagine an export that loads every database row into memory, builds one large CSV string, then sends it. It passes with a tiny test dataset. If the export must support large datasets, an engineer familiar with streaming can read bounded batches and write output as it becomes available, while respecting how quickly the receiver can accept it. That deserves a test with realistic data during development. So does a browser application that downloads a large charting library on every visit when only an optional report needs it. A team can inspect the bundle and consider loading that code when the report opens. Neither choice needs imaginary millions of users. Both have costs worth checking now. Postpone them repeatedly and other code may start depending on the original behaviour. Add a cache to hide the slow query, then another feature that assumes the cache exists, and the eventual fix has more moving parts. A backlog entry does not keep a problem from growing.

SQLite offers a useful answer to the dismissal of small gains. Its account of CPU performance work describes repeatable measurements with Cachegrind and changes that individually save as little as 0.05 percent in the measured work. Its historical comparison reports that the 2025 version needed about 29 percent of the CPU cycles reported for the 2008 version on its standard workload under Cachegrind. That is a result under a particular benchmark and tool setup. Results will vary between applications. The useful point is that SQLite makes performance work part of development and lets measured gains accumulate. Small improvements can be worth keeping when the code runs often enough and the maintenance cost makes sense. SQLite is a mature project, so this example does not prove what every new product should do. It does show a working alternative to letting efficiency become a permanently postponed task.

I also care about what the first implementation teaches the rest of the system to expect. Suppose that export becomes a shared function that returns the entire file as one value. Several callers now expect to receive the complete file before they do anything. Changing it to stream output may require changes in those callers, their error handling, and their tests. The original shortcut has spread beyond the code that introduced it. A team could keep the old interface and move the export to a larger machine or a background worker. Either might be a sensible choice, but I want the team to examine why the export needs so much memory before adding another component around it. Technical debt can change the next decision, then the one after that. That is why I want known constraints considered while the first implementation is still small.

Experience should lead to better decisions

Having time gives an experienced individual or team room to investigate. I want that room used. Check the query plan. Measure the allocation. Try the smaller dependency. Compare the change against the same realistic workload, and check that the behaviour stays correct. Experience should help someone choose a useful experiment and recognise when the result fails to justify the complexity. It should also make them willing to show their reasoning to a colleague. Seniority alone proves nothing about which implementation is faster. There are honest reasons to defer work, including a real deadline, an uncertain product requirement, or a gain too small to justify the upkeep. When I choose to defer a known cost, I want to record what would make it worth revisiting. “We will optimize later” is a weak decision when later has no owner, no condition, and no time reserved. Spare capacity is a good time to pay down a known cost while the code is still easy to change.

Leadership has a part in this too. If a senior engineer points out an avoidable cost and there is room in the schedule, I want them to have time to investigate it during work. Ask what they expect to improve, how they will check it, and how much time the experiment needs. Give them an agreed stopping point and let them work. A junior who notices repeated database calls should have room to ask about them without hearing that performance belongs to a future team. I would rather a senior help them inspect the requests and understand the result. That develops judgement alongside the feature. A company that fills every available hour with new features has chosen how much room remains for this work. I want that choice made openly, with someone responsible for the costs being deferred. Calling every proposed improvement premature makes it too easy to avoid that conversation.

I want optimization treated as part of writing the product from day one, with evidence guiding how far it goes. When the team has the experience and the time, avoiding known waste belongs in the work. A familiar quote is a poor excuse for leaving a problem you already know how to solve.