Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
What is Redis?  ›  Lesson

Redis vs SQL and NoSQL Databases

Redis vs SQL/NoSQL DBs 12 minChoose Redis when you know exactly which key you will ask for and need the answer in well under a millisecond; choose a SQL or document database when you need ad-hoc queries, joins or a dataset larger than memory.

Redis vs SQL and NoSQL Databases

A new Wordcraft developer suggests moving the whole game into Redis "because it is faster". Another wants to drop Redis "because PostgreSQL can do everything". Both are missing the point: the stores answer different kinds of question, and most real apps use both.

The rule

Redis answers questions you can name by key; databases answer questions you describe.

A SQL database (PostgreSQL, MySQL) lets you describe what you want: "players from Pune who joined in March, sorted by coins". It plans a search, uses indexes, joins tables, enforces relationships and keeps data safely on disk. Its dataset can be far larger than memory.

A document or wide-column NoSQL database (MongoDB, Cassandra) relaxes the fixed tables but still lets you query by fields inside the data and stores it mainly on disk.

Redis is a key-value store. You must know the key: player:asha, leaderboard, session:9f2c. Core Redis has no WHERE clause over values and no joins (add-on modules such as Redis Search add indexes, but they are beyond the fundamentals). In exchange, a lookup by key is served straight from memory, and the built-in structures (sorted sets, lists, sets) do work that would otherwise need a query.

Question Best fit
What is Asha's score right now? Redis
Who are the top ten players? Redis (sorted set)
Which Pune players spent over 500 coins in March? SQL
What did player 1042 buy last year? SQL

When to choose Redis: the data is small enough for RAM, you always reach it through a known key, you need answers in well under a millisecond, or the data has a lifetime (cache, session, rate limit). When not to: you need ad-hoc filtering, relationships between records, or a dataset much bigger than memory. Then Redis sits beside the main database, never instead of it.

The shortcut

Read the question aloud. If you can say the key before you ask, it is a Redis question. If you have to describe conditions, it is a database question.

"How many games did Ravi play today?"Step 1 of 4
  1. Can you name the key?

    Yes: a counter such as games:ravi:2026-09-25.

The trap is speed-only thinking. Redis being faster per lookup does not help if you would have to fetch every key and filter in your app.

Drills

Answer fast — trust the rule.

quick drill

Which query is a poor fit for Redis?

quick drill

Why can a Redis key lookup be faster than a SQL query for the same single value?

quick drill

The game history is 2 TB and grows every day. Where should it live?

quick drill

What does Redis lack that a SQL database provides?

Remember

  • Redis answers questions you can name by key; databases answer questions you describe.
  • If you can say the key before you ask, it is a Redis question.
  • Most apps use both: a durable database for records, Redis for the hot layer.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainRedis or PostgreSQL?

Wordcraft needs to answer two questions: 'What is Asha's current score?' on every screen, and 'Which players from Pune joined in March and have spent more than 500 coins?' once a month for a report. Say which store should answer each question and why.