Precomputation
Precomputation is calculating results before they are needed so they can be reused later without repeating the calculation.
Microservices Patterns, Second Edition
The calculation of values in advance so they can be stored and retrieved rather than recomputed for each query.
- How it is used
- Uses precomputation as a CQRS view-schema choice for improving query efficiency while accounting for event-handler update costs.
- How deep it goes
- Explains the schema decision and its scale-related trade-offs, but does not detail a precomputation procedure.
- Examples
- Illustrates query-supporting restaurant latitude and longitude for a proximity filter.
- What you can do after
- Evaluate whether query scale justifies precomputation and related schema optimizations over a simpler normalized design.
Read how Microservices Patterns, Second Edition explains precomputation →
Latency
The calculation of results before they are needed so later operations can retrieve or reuse them without repeating expensive computation.
- How it is used
- Reduces latency by moving expensive computation out of latency-sensitive code paths.
- How deep it goes
- Develops build-time, startup, runtime-interval, lookup-table, stale-data, and incremental-update strategies.
- Examples
- Uses storage statistics involving filesystem or database queries, subscription quotas, discounts, forecasting, and periodic refreshes.
- What you can do after
- Apply it by choosing a precomputation time and serving stored results through a lookup instead of repeating expensive logic.
Machine Learning System Design
Precomputation performs a calculation before its result is needed so that later processing can reuse the stored result.
- How it is used
- Reduces feature-store read latency by calculating reusable features before dataset retrieval.
- How deep it goes
- Defines precomputation, then explains staged aggregation, reuse, overlapping windows, and batch/real-time serving tradeoffs.
- Examples
- Uses clicks, prices, revenue, item-day sums, and 7-, 14-, 30-, and 60-day aggregation windows.
- What you can do after
- Apply it via a feature store to reuse staged aggregates and combine them with real-time features.
Read how Machine Learning System Design explains precomputation →
Also covered in
- AI Recommender SystemsIn early access (MEAP)
What to know first
- meanThe mean is a measure of central location equal to the arithmetic average of numerical observations, or the probability-weighted average of a random variable’s possible values.
Related concepts
- meanaddresses · The mean is a measure of central location equal to the arithmetic average of numerical observations, or the probability-weighted average of a random variable’s possible values.
- materialized viewimplemented by · A materialized view is a persistently stored result of a defining query that can be read without recomputing it and is refreshed or maintained from underlying data.
- Mapproduces · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- incremental processingincludes · Incremental processing updates results or state by processing only inputs or tasks affected by changes, rather than recomputing everything.
- don't repeat yourself principleuses · The Don’t Repeat Yourself principle is a software design guideline that gives each piece of knowledge or behavior a single authoritative representation to avoid unnecessary duplication.
Questions about precomputation
What is precomputation?
Precomputation is calculating results before they are needed so they can be reused later without repeating the calculation.
Which Manning books explain precomputation?
Microservices Patterns, Second Edition, Latency and Machine Learning System Design.
What should I know before learning precomputation?
Manning books that teach precomputation usually introduce mean first.
What kinds of precomputation are there?
Kinds of precomputation include incremental processing.
What is precomputation also called?
Precomputation is also called precalculation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


