Scrivio Interview library

MySQL and InnoDB

30 questions in 10 subtopics.

InnoDB architecture and buffer pool

InternalsFoundations7 min read
Describe the main parts of InnoDB's memory and disk architecture: buffer pool, change buffer, adaptive hash index, log buffer, redo log, undo tablespaces and the doublewrite buffer. What does each do?
ScenarioIntermediate6 min read
A MySQL 8.4 server with 64 GB RAM has innodb_buffer_pool_size=8G. Reads are slow and disk read IOPS are high. How do you size the buffer pool, what metrics confirm the problem, and can you change it without a restart?
DesignAdvanced6 min read
You run 300 MySQL instances on cloud VMs. Costs are high because every instance is sized for peak memory. How would you approach right-sizing and standard configuration across the estate?
LeadershipPrincipal6 min read
Oracle moved MySQL to an Innovation and LTS release model (8.4 is LTS), while forks such as Percona Server and MariaDB went their own ways and cloud vendors offer compatible engines like Aurora. How do you choose a MySQL distribution and upgrade cadence for a company with 300 instances?

Clustered primary key

ConceptFoundations8 min read
In InnoDB, what happens if a table has no primary key? Why does the choice of primary key affect the size of every secondary index?
DesignIntermediate7 min read
You are designing an orders table in MySQL that will reach 2 billion rows. The most frequent query is 'orders of a customer ordered by date'. Compare PRIMARY KEY (id) with a secondary index (customer_id, created_at) against PRIMARY KEY (customer_id, created_at, id).
DesignAdvanced7 min read
Teams across your company use different primary key styles in MySQL: auto-increment BIGINT, CHAR(36) UUIDs, and composite natural keys. Propose a standard and the migration approach for existing tables.

Redo and undo logs

InternalsFoundations7 min read
What is the difference between InnoDB's redo log and undo log? What does innodb_flush_log_at_trx_commit control, and what are the risks of setting it to 2 or 0?
DebuggingIntermediate7 min read
SHOW ENGINE INNODB STATUS reports 'History list length 48000000' and queries on a hot table slow down steadily during the day. What causes this and how do you resolve it?
ScenarioAdvanced7 min read
A write-heavy MySQL 8.0 primary shows periodic stalls of several seconds where writes freeze. Metrics show the checkpoint age approaching redo capacity. Explain the cause and the tuning and upgrade options.
DesignPrincipal6 min read
Your finance team asks for a guarantee that no committed transaction is ever lost, while the product team wants the lowest write latency. How do you set and communicate durability standards for MySQL across the company?

Gap and next-key locks

ConceptFoundations7 min read
At REPEATABLE READ in InnoDB, what are record locks, gap locks and next-key locks? Why can SELECT ... FOR UPDATE WHERE id BETWEEN 10 AND 20 block an INSERT of id 15 even if no row 15 exists?
DebuggingIntermediate7 min read
Two transactions run concurrently: each does SELECT * FROM slots WHERE room=1 AND day='2026-11-05' FOR UPDATE, finds no row, then INSERTs one. The application sees 'Deadlock found when trying to get lock'. Explain step by step and fix it.
LeadershipPrincipal6 min read
Your services moved between PostgreSQL and MySQL over the years, and lock-related incidents keep recurring because engineers assume one engine's isolation behaviour. What would you standardise across the company about isolation levels and locking?

Binlog and replication

ConceptFoundations6 min read
What is the MySQL binary log used for? Compare statement-based, row-based and mixed binlog formats, and explain what GTIDs add.
DebuggingIntermediate6 min read
A read replica falls 2 hours behind every night when a batch job runs UPDATE events SET archived=1 WHERE created_at < now() - interval 90 day on 40 million rows. How do you diagnose and fix it?
DesignAdvanced6 min read
Design a highly available MySQL setup for a payments service that must not lose committed transactions on primary failure, and compare async replication, semi-synchronous replication and Group Replication / InnoDB Cluster.

MySQL vs PostgreSQL

ConceptFoundations6 min read
Name five practical differences between MySQL InnoDB and PostgreSQL that matter to a Java developer writing queries and migrations.
ScenarioAdvanced6 min read
You must migrate a 3 TB MySQL 5.7 database (end of life) to either MySQL 8.4 or PostgreSQL 17 with less than 10 minutes of downtime. How do you choose and plan each path?
LeadershipPrincipal6 min read
A new business unit asks whether to choose MySQL or PostgreSQL for all of its new services for the next ten years. How would you frame and make the decision?

Online schema change tools

ConceptFoundations6 min read
Why can ALTER TABLE be dangerous on a large MySQL table in production, and what do ALGORITHM=INSTANT, INPLACE and COPY mean?
ScenarioIntermediate7 min read
You must change a column type from INT to BIGINT on a 1.5 billion row MySQL table that serves 5,000 writes per second. Compare gh-ost and pt-online-schema-change and describe the execution plan.
DesignAdvanced6 min read
Schema changes across 120 MySQL databases are run by hand by a few DBAs and cause occasional outages. Design a self-service schema change process for developers.

Character sets and collations

DebuggingFoundations7 min read
A Spring Boot app stores user names in MySQL and emoji become '????' or the insert fails with 'Incorrect string value: \xF0\x9F...'. Why, and how do you fix it end to end?
ScenarioIntermediate6 min read
After converting tables to utf8mb4_0900_ai_ci, a unique index on username starts rejecting new users named 'jose' because 'JOSE' or an accented spelling of the same name already exists, and some joins between tables return fewer rows. Explain and decide on a collation policy.

Storage engines

ConceptFoundations6 min read
MySQL supports several storage engines. Compare InnoDB, MyISAM and MEMORY, and say why MyISAM is considered legacy today.
ScenarioAdvanced6 min read
An acquired company runs a 10-year-old MySQL 5.6 system with 400 MyISAM tables, nightly table corruption repairs, and no replicas. Plan the move to a supported, InnoDB-based setup.

Query cache history and alternatives

ConceptFoundations5 min read
MySQL had a query cache that was deprecated in 5.7 and removed in 8.0. What did it do, why was it removed, and what do you use instead?
DesignIntermediate6 min read
After an upgrade from MySQL 5.7 to 8.0, a reporting service that relied on the query cache sees database CPU triple. Design the replacement caching approach.
LeadershipPrincipal7 min read
The MySQL query cache, Hibernate second-level cache defaults and several in-house caches all caused incidents in your company's history. What principles would you set for caching across the organisation?