Denormalization
Денормализация
A database can store extra copies or precomputed results so common queries do less work. This makes reads simpler, but writes and refresh jobs must keep the stored values in sync.
What denormalization means
Normalization gives each fact a single home. For instance, a customer's current name lives in the customer table, and orders refer to that customer by ID. Denormalization deliberately adds redundancy for a particular access pattern. You might copy a field into another table or store a total that could otherwise be calculated from individual rows. Either way, the database does some work before the read so it doesn't have to repeat that work on every request.
Example: a reporting dashboard
Suppose a dashboard shows the number of orders and gross sales for every store by day. It could group raw order rows each time someone loads the page. Instead, a reporting job can maintain a daily_store_sales table with one row per store and date. The dashboard then reads the stored totals:
SELECT sale_date, order_count, gross_sales
FROM daily_store_sales
WHERE store_id = 42
ORDER BY sale_date DESC
LIMIT 30;
The order records remain the source of truth. If an order arrives late or its amount is corrected, the reporting job must update or recompute the affected day's totals. Otherwise the query may be fast but wrong.
The cost of keeping data in sync
If the summary must reflect every committed order change immediately, you can maintain it in the same database transaction as the order. That adds work to writes, and concurrent writes may contend for the same summary row. If the dashboard can tolerate a delay, a background job can refresh the summary instead. Specify how stale it may get and how to rebuild it from the source if a refresh fails. An increment-based job also needs to handle retries without counting the same order twice.
When to use it
Stored summaries and materialized views are common in reporting. In operational systems, teams sometimes copy a frequently requested field into a read-oriented table to avoid a costly join. A regular SQL view can simplify the query you write, but it does not normally store the result. Likewise, a historical snapshot such as the shipping address used for an order is not a copy to keep in sync with the customer's current profile: it represents a different fact.
A join is not automatically a bottleneck. Inspect the query plan and test indexing or query changes before adding redundant data. Compare read latency, write cost, and storage on a realistic workload, not just the fastest dashboard query in isolation.
In an interview
Start with the expensive query and how often it runs. Then explain what you would store, which data is authoritative, how fresh the result needs to be, and how you would recover if the stored copy drifted. The key trade-off is less work on reads in exchange for more work maintaining the stored data.