Loading…
SQL, MongoDB, Redis, and caching patterns
Data-layer interviews test both breadth (SQL indexes, ACID, sharding; NoSQL document models; Redis structures) and depth (N+1, cache invalidation, partitioning). This hub covers all three modules with scenario-based questions drawn from real production incidents.
How to use this hub
4 modules cover databases & caching end-to-end. Open the first module, use Open question 1 on its landing page, and use Next at the bottom of each answer to stay in order.
Revision sheet
~12 min · 5 sections · save as PDF
SQL interview questions are unavoidable in any backend interview — joins (inner, outer, cross, self), subqueries vs joins, window functions, indexes (B-tree vs hash, when an index hurts), the EXPLAIN plan, transaction isolation levels, ACID, normalization, sharding, partitioning, replication, connection pooling, and migration tools (Flyway, Liquibase). This page covers cross-database SQL fundamentals plus the operational questions that decide a senior interview. For Postgres-specific deep dives (window functions, JSONB, MVCC, partitioning), use the dedicated PostgreSQL page; for MongoDB, see the MongoDB page; for Redis, see the Redis page.
Three lenses senior interviews probe:
EXPLAIN is your evidence. Always read the plan, not the SQL.
The interview surface for this module breaks into these focus areas:
WHERE func(col), leading wildcard LIKE '%x', mismatched types, low selectivity.connections × instances against DB max."I'd write the query, run `EXPLAIN ANALYZE`, look for
on the hot path, fix it with , and only after the query is tight do I think about ."
Revision sheet
~12 min · 5 sections · save as PDF
PostgreSQL interview questions go beyond generic SQL — MVCC and the PostgreSQL transaction model, JSONB indexing strategies, partitioning (declarative + inheritance), the rich window-function vocabulary, replication (streaming + logical), backup and PITR strategy, query planning with EXPLAIN ANALYZE, and the Spring Boot + HikariCP tuning patterns that surface in real interviews. This page is the one to use when the job description specifies Postgres (which is most of them in 2026).
Postgres = relational core + power-user extras.
The interview surface for this module breaks into these focus areas:
jsonb_ops vs jsonb_path_ops.pg_basebackup and walsender."For Postgres I'd lean on
because , watch for , and tune for the workload before reaching for sharding."
Revision sheet
~12 min · 5 sections · save as PDF
MongoDB interview questions cover the document data model in interview depth — schema design (embedded vs referenced), indexes (compound, multikey, text, geo), the aggregation pipeline, sharding and zone sharding, replica sets and read concerns, consistency trade-offs (eventual, causal, linearizable reads), and integration with Spring Data MongoDB. Expect senior interviews to compare MongoDB to a relational store and probe on operational concerns (rebalancing, backup, election).
MongoDB is a document store with a strong query language.
The interview surface for this module breaks into these focus areas:
$lookup knowing it's the perf cost."I'd model the entity as
because , index it on , run reads against secondaries with read concern , and shard on if writes outgrow a single replica set."
Revision sheet
~12 min · 5 sections · save as PDF
Redis and caching interview questions test whether you understand caching as a system, not just a library — Redis data structures (strings, hashes, lists, sets, sorted sets, streams, HyperLogLog), eviction policies (LRU, LFU, allkeys vs volatile), persistence (RDB, AOF), replication and Sentinel/Cluster modes, cache-aside vs read-through vs write-back, distributed locking (Redlock and its critics), and the common pitfalls (cache stampede, hot keys, big keys). This page is the one to use for any role that mentions Redis or distributed caching.
Redis is a single-threaded in-memory data structure server — speed comes from O(1) ops + simple ops.
The interview surface for this module breaks into these focus areas:
volatile-* only on TTL-set keys."I'd cache
via cache-aside with TTL , tolerate eventual consistency on writes via , pick the data structure as , and guard against stampede with ."