Denormalization: Trading Write Speed for Faster Reads
Denormalization speeds up database reads by intentionally adding redundant data, trading write-speed for read-performance. Use it for read-heavy systems like reporting dashboards where joins are too slow.
WHY IT EXISTS Normalized databases are designed to minimize data redundancy, which is great for data integrity and efficient writes. However, this means retrieving data often requires complex and slow JOIN operations across multiple tables. In read-heavy applications, these joins can become a major performance bottleneck.
THE MENTAL MODEL Think of denormalization as pre-calculating the answers to your database's most frequent and expensive questions. Instead of joining tables A, B, and C every time a user loads a page, you create a new table or add columns that already contain the combined data. You trade storage space and write complexity for near-instant read access.
HOW IT WORKS Denormalization is the process of adding redundant data to a previously normalized database. This can be done by adding copies of data (e.g., storing a user's name in a comments table alongside their user ID to avoid a join to the users table) or by grouping data (e.g., creating summary tables that store pre-computed values, like total sales per day).
WHEN TO USE IT Use denormalization when read performance is a critical requirement and you have identified specific, slow queries that are executed frequently. It is ideal for systems with a high read-to-write ratio, such as analytics dashboards, content management systems, or e-commerce catalogs where product details are read far more often than they are updated.
WHEN NOT TO USE IT Avoid denormalization in write-heavy systems, like online transaction processing (OLTP) systems, where data consistency is paramount and write performance is critical. The overhead of updating redundant data can slow down writes and introduce bugs. It should never be a premature optimization; always start with a normalized design and only denormalize based on performance data.
ONE CANONICAL EXAMPLE An e-commerce site has a products table and a categories table. To display a product's category name, you would normally join them. In a denormalized design, you would add a category_name column directly to the products table. This makes reads faster (no join needed) but means if a category name changes (e.g., "Books" to "Literature"), you must update it in the categories table and in every single product row belonging to that category.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.