Skip to content
slang.fyi

premature optimization

/prɪˈmætʃər ˌɒptɪmaɪˈzeɪʃən/

Common

Making code faster before you know what's actually slow.

The quote 'premature optimization is the root of all evil' is from Knuth but usually misused. Knuth was specifically talking about micro-optimizations in hot paths, not all optimization.

Real-world examples4 examples
#ExampleWhat it meansSource
01he rewrote the whole query to avoid a join on a table with 200 rows. premature optimization.The optimization target was too small to matter and added complexity for no benefit.reddit, 2023
02me: I profiled it and the bottleneck is the DB. coworker: but have you optimized your string formatting. me: ...premature optimization broSomeone is focused on a tiny issue while the real problem is identified and elsewhere.x, 2024
03added memoization before writing the tests. king of premature optimization right hereOptimizing before even knowing if the code is correct or if performance matters.x, 2023
04the Knuth quote gets misused so much. he wasn't saying never optimize. he was saying measure first.Correcting a common misapplication of the 'premature optimization' concept.x, 2024

Use it when

  • Someone is optimizing a code path that runs once on startup.
  • A PR sacrifices readability for speed gains that haven't been measured.
  • Someone added caching before profiling to find the actual bottleneck.

Do not use it when

  • The code has been profiled and the hotspot is confirmed.
  • You mean someone is designing for scale too early.Use “over-engineering” instead.

Premature optimization vs over-engineering

premature optimization

Premature optimization is about performance work done before measurement.

VS

over-engineering

Over-engineering is about structural complexity added before it's needed.

Origin and context

The phrase comes from Donald Knuth's 1974 paper 'Structured Programming with go to Statements': 'We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.' The full quote is almost never used.

First seen
1974
Confidence
high

Cite this page

Use this stable URL to reference the entry.

https://slang.fyi/premature-optimization
Updated: 2026-08-28License: CC BY 4.0

Related slang