Premature Optimization
Updated 2026-07-30
Summary
Optimizing before identifying the bottleneck adds complexity and waste.
Definition
Premature optimization means investing substantial effort in small performance improvements without adequate requirements or measurements, potentially adding complexity for little benefit. Knuth criticized excessive attention to small efficiencies while emphasizing opportunities in critical parts; this does not prohibit early consideration of algorithms or performance goals.
Introduction
How to use
Require a goal, measurement basis, and expected benefit for performance work so effort is directed toward bottlenecks that affect user requirements.
Mechanism
Prematurely polishing details when requirements and bottlenecks are unclear wastes resources and is often based on wrong assumptions, making the system harder to modify.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- Hypothetical example: A team proposes hand-optimizing a rarely called function, but measurements show that repeated database queries dominate request time. Reduce repeated queries and measure again before deciding whether to change that function.
Common pitfalls
- Do not interpret the warning as a reason to postpone all performance work until the end; late changes to algorithms, data structures, or capacity constraints may require a rewrite. Cleanliness and performance are separate judgments, and optimization should be assessed against goals and evidence.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Program_optimizationverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS