Skip to content

Denormalization

一句话解释

Denormalization 是 intentional 处理的 duplicating 数据跨越表 到速度上 读取通过 avoiding 连接.

用大白话说

Denormalization is the opposite of normalization — you deliberately store redundant data to improve read performance. Instead of joining three tables to get a user's order with their city, you store the city name directly in the orders table.

这个trades write complexity (you must update the city in every order when it changes) for read speed (no joins needed). It is common in read-heavy systems like analytics dashboards, reporting, and data warehouses.

Denormalization is a deliberate design choice, not an accident. You normalize first to ensure data integrity, then selectively denormalize the hot paths that are read often but updated rarely.

示例

sql
-- Denormalized: store the city name directly in orders
CREATE TABLE orders_denorm (
  id        SERIAL PRIMARY KEY,
  user_name TEXT,
  user_city TEXT,  -- duplicated from cities table
  total     NUMERIC
);
-- Fast reads: no JOIN needed, but city must be updated everywhere if it changes

存储 user_name and user_city directly avoids 连接但 创建 redundancy 到 maintain.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表