Backend Developer
Databases and caching questions
189 questions on Databases and caching for backend developers, easiest first.
Easy 49
- Redis TTL after SET with EXeasy
- Embed or reference in MongoDBeasy
- Building SQL from user inputeasy
- What atomicity guaranteeseasy
- WHERE column = NULL finds nothingeasy
- COUNT(*) versus COUNT(column)easy
- Column type for priceseasy
- Storing order times for two countrieseasy
- Students and courses table designeasy
- What a foreign key doeseasy
- Rows come back in a new ordereasy
- Search with a leading wildcardeasy
- Deleting a customer with ON DELETE CASCADEeasy
- Missing numbers in order idseasy
- Where to keep product photoseasy
- Inserts fail at 2.1 billioneasy
- Checking if any rows existeasy
- What is inside a MongoDB ObjectIdeasy
- MongoDB's maximum document sizeeasy
- Updating a counter in MongoDBeasy
- Fields vanish after an updateeasy
- Counting API calls in Rediseasy
- KEYS * freezes production Rediseasy
- Storing a user profile in Rediseasy
- What TTL returns for a keyeasy
- Naming Redis keyseasy
- Cache empty after a Redis restarteasy
- Deleting old sessions in MongoDBeasy
- Finding products by tageasy
- Missed Redis pub/sub messageseasy
- Create the document if it is missingeasy
- A simple job queue in Rediseasy
- What a 92% cache hit ratio meanseasy
- Which key an LRU cache evictseasy
- Why cache entries have a TTLeasy
- Arabic text shown to English userseasy
- What a write-through cache doeseasy
- Slow responses after a cache restarteasy
- An address changed in one place onlyeasy
- RPO versus RTOeasy
- Backups that nobody has restoredeasy
- Database busy with report querieseasy
- SQLite says 'database is locked'easy
- Redis Pub/Sub for jobseasy
- Serving images to far-away userseasy
- The cache-aside patterneasy
- Scaling a read-heavy databaseeasy
- Cost of adding indexeseasy
- A live game leaderboardeasy
Medium 73
- The N+1 query problemmedium
- Cache-aside patternmedium
- Response to a matching If-None-Matchmedium
- Redis structure for a leaderboardmedium
- Keeping a cached price freshmedium
- CDN serves one user's profile to anothermedium
- What a dirty read ismedium
- The same row read twice gives two valuesmedium
- PostgreSQL's default isolation levelmedium
- MySQL InnoDB's default isolation levelmedium
- FOR UPDATE that locks nothing usefulmedium
- Several workers taking jobs from a tablemedium
- Page view counter loses countsmedium
- Insert or update in one statementmedium
- Two accounts with one emailmedium
- Case-insensitive lookup ignores the indexmedium
- Phone lookup does a full table scanmedium
- A query answered from the index alonemedium
- Indexing only the pending ordersmedium
- Index on a true/false columnmedium
- Deleting a customer takes minutesmedium
- Pool runs dry after some errorsmedium
- A list page loads huge rowsmedium
- One query escapes the transactionmedium
- Importing 100,000 rows slowlymedium
- Rows skipped with created_at cursorsmedium
- findOneAndUpdate returns the old valuemedium
- Speeding up read-only Mongoose queriesmedium
- A new field is never savedmedium
- Ordering fields in a MongoDB indexmedium
- A slow aggregation pipelinemedium
- A chat document keeps growingmedium
- Reads from secondaries miss new datamedium
- A confirmed write disappears after failovermedium
- Case-insensitive unique emails in MongoDBmedium
- Logging in with an operator as passwordmedium
- Heavy $lookup on every pagemedium
- Rate limit key that never expiresmedium
- Redis cache errors when memory is fullmedium
- 500 Redis calls per requestmedium
- A Redis transaction does not roll backmedium
- Cached keys stop expiringmedium
- Counting daily unique visitorsmedium
- Durable events with Redismedium
- Releasing a Redis lock safelymedium
- One huge key slows Redismedium
- Average read time with a 90% hit ratiomedium
- Thousands of keys expiring togethermedium
- Requests for ids that do not existmedium
- Updating or deleting the cache on writemedium
- Different prices on different serversmedium
- Serving slightly old data while refreshingmedium
- Dates break after cachingmedium
- A memoised function eats memorymedium
- Clearing all catalogue cache keys at oncemedium
- The risk of a write-behind cachemedium
- Copying the author name into postsmedium
- Querying inside a JSONB columnmedium
- Searching article text with LIKEmedium
- Committed orders missing after failovermedium
- A dashboard shows yesterday's totalsmedium
- Why databases index with B-treesmedium
- In-memory Map cache across many serversmedium
- App keeps failing after failovermedium
- Serving stale data during an outagemedium
- Replicas do not protect from bad deletesmedium
- Rollback breaks after a migrationmedium
- Write-through caching trade-offmedium
- Average latency with a cachemedium
- Stale data from a read replicamedium
- Paging through a huge feedmedium
- What a Bloom filter answersmedium
- A like counter on a viral postmedium
Hard 67
- Cache stampede on a hot keyhard
- Connection pools and autoscalinghard
- Profile shows old data after savinghard
- Adding a fifth cache nodehard
- Sharding orders by creation datehard
- Stale value returns after cache deletehard
- Trusting a Bloom filter answerhard
- Inserts slow down with UUID keyshard
- Pool exhausted during paymentshard
- Range updates mixed with range querieshard
- Removed admin can still delete usershard
- A transaction spread across connectionshard
- Features that break behind PgBouncerhard
- Errors under Serializable isolationhard
- Deadlocks in money transfershard
- Both doctors go off callhard
- Tables grow though rows are deletedhard
- Adding an index without blocking writeshard
- Which new column rewrites the tablehard
- Backfilling a new column on a big tablehard
- Migrations run on every pod starthard
- Order saved but event never senthard
- A queue message applied twicehard
- One counter row slows every salehard
- Two admins edit the same producthard
- A bad query takes the database downhard
- Two workers both think they hold the lockhard
- CROSSSLOT errors after moving to Clusterhard
- Eviction policy set, but writes still failhard
- Jobs lost when workers crashhard
- Transactions fail on a local MongoDBhard
- One write escapes a MongoDB transactionhard
- Billions of tiny sensor documentshard
- Some orders never match a queryhard
- One Redis key gets half of all traffichard
- How much data AOF everysec can losehard
- Keeping wallet balances only in Redishard
- Keeping only the last 50 notificationshard
- All inserts land on one shardhard
- Two payment retries run at oncehard
- A Lua script stalls every clienthard
- Sharding by tenant with one giant tenanthard
- A report across all shardshard
- Search shows deleted productshard
- Deleting old log rows every nighthard
- Two kinds of database timeouthard
- The connection dropped during COMMIThard
- New code crashes on old cache entrieshard
- A join across two services' databaseshard
- A query with 20,000 ids in IN (...)hard
- Emoji in reviews fail to savehard
- 'José' blocked because 'Jose' existshard
- BFS over a graph stored in SQLhard
- Detecting a database deadlockhard
- Same request, two cache entrieshard
- One key overloading a cache shardhard
- Designing an O(1) LFU cachehard
- Hash index vs B-tree indexhard
- The cache becomes criticalhard
- Queries keep running after the client quitshard
- Errors cached at the edgehard
- Reliable job queue on Redis listshard
- Requests for keys that do not existhard
- Risk of a write-back cachehard
- Random UUIDs as primary keyshard
- Designing a wallet ledgerhard
- Throttling on one partition keyhard