Review cards · 22 cards
Databases
Indexes, storage engines, transactions and choosing a data store.
Cards
- Postgres starts a process for each connection, so thousands of app instances should share a small number of connections through a pooler such as _____.
- An index makes reads on a column fast. What does it cost?
- What is the N+1 query problem, and how do you fix it?
- Which workload most clearly calls for a relational database?
- Before acknowledging a commit, a database appends the change to its _____ and flushes it to disk, so a crash can be recovered by replaying it.
- A table has an index on (country, city). Which query cannot use it efficiently?
- In a flash sale, how do you decrement stock so it never goes below zero?
- A service runs 2,000 queries/s, and each query holds a database connection for 5 ms. On average, how many connections are busy?
- What makes an index covering for a query, and why is it faster?
- When would you denormalize a schema, and what do you take on?
- You need to split full_name into first_name and last_name on a busy table, while old app versions keep reading full_name. Which order does it with no downtime and no broken readers?
- Which column gains the least from a B-tree index of its own?
- An LSM tree first puts writes in an in-memory _____, flushes it to disk as immutable sorted files called _____, and merges those files in the background, which is called _____.
- Why not run the analytics team's big reports on the production database?
- Why does a backfill of millions of rows run in small batches from a background job, after dual writes have started, rather than as one UPDATE before them?
- When does pessimistic locking (SELECT … FOR UPDATE) beat optimistic concurrency (a version check at write time)?
- A service ingests millions of small writes a second and reads them rarely. Which storage engine design suits it best?
- A key in an LSM tree may be in any of dozens of SSTables. What keeps reads from checking all of them?
- How does MVCC let readers and writers avoid blocking each other, and what does it cost?
- Why can random (v4) UUID primary keys make inserts slow on a large B-tree table?
- Under read committed isolation, which of these can still happen inside a single transaction?
- Two doctors are on call. Each, in their own transaction, checks "at least two are on call" and takes themselves off. Both commit, and no one is on call. What anomaly is this, and how do you prevent it?
More topics
- Estimation 21 cards
- Networking 16 cards
- API design 17 cards
- Caching 21 cards
- Replication 15 cards
- Sharding 18 cards
- Consistency 19 cards
- Queues 18 cards
- Streaming 18 cards
- Availability 14 cards
- Resilience 16 cards
- Storage 14 cards
- Realtime 15 cards
- Data structures 16 cards
- Security 17 cards
- Observability 18 cards
- Coordination 16 cards