Course contentsShow
← System Design
Lesson 1660 of 1,91940. Real-World System: Social Media FeedFree lesson

Denormalized Timeline Tables

How to design denormalized feed tables that duplicate data for fast reads without expensive joins or aggregations.

Denormalized Timeline Tables

What You'll Learn

You'll learn how to design feed storage that duplicates post data into user timelines for instant reads, trading storage space for query speed.


The Core Idea

In a normalized database, you'd store posts once and query them by joining with the follow graph at read time. But when millions of users open their feeds simultaneously, those joins become prohibitively expensive.

Denormalized timeline tables flip this: during fanout-on-write, you copy each post's essential data directly into every follower's personal timeline table. Now reading a feed becomes a simple key-value lookup—no joins, no aggregations, just "give me the last 20 rows for user_id=12345."

What Gets Duplicated

Each timeline row contains:

  • user_id (the feed owner)
  • post_id
  • author_id
  • timestamp
  • content_preview or media_url
  • Optional: engagement counts, author metadata

This data is redundant—the same post appears in thousands or millions of timeline rows—but the trade-off is worth it: reads are O(1) key lookups instead of O(followers) joins.

Storage vs Speed Trade-Off

Yes, you're storing massive duplicate data. A post with 1M followers creates 1M timeline entries. But disk is cheap; CPU and latency are expensive. Modern feeds prioritize sub-100ms load times, which denormalized tables enable trivially.

Think of it like keeping a pre-printed newspaper for each subscriber rather than printing on-demand when they ask for one.


Key Takeaway:
Denormalized timeline tables duplicate post data into per-user rows, transforming complex read-time joins into simple indexed queries at the cost of increased storage—a classic space-for-time trade-off.