Storage engine internals
22 questions in 8 subtopics.
Pages and the buffer pool
What is a database page, and what is the buffer pool? Explain why reading one 100-byte row by primary key can read a whole page, and what the page sizes are in PostgreSQL and MySQL InnoDB by default.A reporting query on PostgreSQL takes 40 seconds the first time and 3 seconds when repeated. EXPLAIN (ANALYZE, BUFFERS) shows "shared hit=120 read=480000" on the first run. Explain the numbers, the role of the OS page cache, and how PostgreSQL and InnoDB protect the cache from large scans.Your company runs 120 PostgreSQL and MySQL databases on cloud instances, and the finance team asks why memory-optimized instances cost so much. How would you decide memory sizing across the fleet, and what data would you collect before downsizing any database?B+ trees
Why do relational databases use B+ trees for indexes instead of binary search trees or hash tables? Estimate the height of a B+ tree index on 1 billion rows with 8 KB pages, and explain why range queries are efficient.A MySQL InnoDB table uses a random UUID (version 4) stored as CHAR(36) as its primary key. Inserts slow down sharply as the table grows past the buffer pool size, and the table is much larger than expected. Explain why, using B+ tree behaviour, and what you would change.In a PostgreSQL fleet, several heavily updated tables have B-tree indexes three to five times larger than after a fresh rebuild, and queries using them have slowed. How do you explain index bloat, and what process do you set up across teams to manage it?LSM trees and compaction
Explain how a log-structured merge tree (LSM tree) stores data: what happens on a write, on a read and during compaction. Name databases or engines that use LSM trees.Compare size-tiered and leveled compaction in an LSM-based store such as Cassandra or RocksDB in terms of read, write and space amplification. A Cassandra table that stores a work queue with many deletes has rising read latency and warnings about scanning many tombstones. What is happening and what do you change?Your company is choosing the storage engine for a new event history service expected to ingest 500,000 events per second, keep 3 years of data and serve per-customer queries. Teams propose PostgreSQL (B-tree based), Cassandra or ScyllaDB (LSM based) and a managed cloud service. How do you frame the decision for the long term?Write amplification
What is write amplification in a database? Name the main sources of extra writes in PostgreSQL and InnoDB when one row is updated, and explain how HOT updates reduce them in PostgreSQL.A PostgreSQL table of 50 million shipment rows gets 5,000 status updates per second. WAL volume is 2 TB per day, replicas lag, and backup costs keep rising. The table has 9 indexes, including one on status and one on updated_at. How do you reduce the write load, and how do you work with the owning team?Checkpoints
What is a checkpoint in a database such as PostgreSQL or InnoDB, why is it needed, and how does it relate to crash recovery time?A PostgreSQL log repeatedly shows: LOG: checkpoints are occurring too frequently (24 seconds apart) HINT: Consider increasing the configuration parameter "max_wal_size". At the same time, write latency spikes during a nightly bulk load. Explain the message, the effect on I/O and WAL, and what you would change.Durability and fsync
What does it mean that a committed transaction is durable? Explain what the database must do before it reports COMMIT success, and what synchronous_commit = off in PostgreSQL and innodb_flush_log_at_trx_commit = 2 in MySQL change.In 2018 PostgreSQL developers found that on Linux a failed fsync could be reported once and then the dirty pages dropped, so a later fsync succeeded although data was lost. Explain the problem, what PostgreSQL changed, and what else can break the durability promise between the database and the disk.Services in your organization store very different data: payments, user sessions, analytics events and chat messages. Some teams turned off synchronous commit for speed, others run synchronous replication everywhere. How would you define durability tiers and the matching database settings?Cloud databases such as Amazon Aurora and Neon separate compute from storage: the log is shipped to a distributed storage layer and pages are rebuilt there, so traditional checkpoints and local fsync work differently. As the person setting the database strategy for your company, how do you evaluate such architectures against classic PostgreSQL on your own volumes?Row stores vs column stores
Explain the difference between row-oriented and column-oriented storage. Why is SELECTSUM(amount) FROM sales over 500 million rows often much faster in a column store, and why is updating a single order slower there?A PostgreSQL table events(80 columns) holds 600 million rows. Analysts run queries like SELECT date_trunc('day', ts), COUNT(*), SUM(value) FROM events WHERE ts > now() - interval '90 days' GROUP BY 1 and each takes 10 minutes. The product team does not want a new database. What options do you have, and what do you recommend?OLTP vs OLAP
Compare OLTP and OLAP workloads: typical queries, data model, concurrency, latency and the databases used for each. Give an example of a query that belongs in each.A company runs all analytics directly on read replicas of its PostgreSQL OLTP databases. Long queries get cancelled with "canceling statement due to conflict with recovery", replicas fall behind, and every team builds its own reports. Design the path to a proper analytics architecture.Your company spends heavily on a cloud data warehouse, runs a separate self-hosted ClickHouse cluster for product analytics, and keeps raw data in object storage. Leadership asks for a five-year data platform strategy. How do you approach build vs buy, open table formats and cost governance?No question matches these choices.