Describe the process and benefits of database 'Denormalization'.
Instruction: Explain why and when you would consider denormalizing a database.
Updated
Official Answer
Denormalization deliberately duplicates or precomputes data to serve a demonstrated access pattern. For example, a maintained daily sales summary can avoid repeatedly scanning all order lines for a dashboard.
Start by measuring the slow query and checking its plan, indexes and data volume. If denormalization is justified, define the authoritative source, refresh mechanism and permitted staleness. A synchronous update may preserve freshness but increase write latency and coordination; asynchronous refresh can reduce that coupling but produces a lagging read model.
Test corrections, deletions, retries and rebuilds, not just inserts. Reconcile the derived data with its source and monitor refresh failures. Measure read improvement against extra storage, write work and operational complexity on representative workloads.
Denormalization can simplify a consumer query while making the whole system harder to maintain. It is not guaranteed to make every query faster, and it should not replace a clear source of truth.
Related Questions
-
medium
-
medium
-
medium
-
medium
-
hard