Q1
What breaks silently if a MySQL application uses legacy utf8 (utf8mb3) instead of utf8mb4?
MySQL's historical utf8 alias supports only 3-byte BMP characters—throwing Incorrect string value crashes or truncating strings whenever users submit 4-byte emojis, Tamil/rare mathematical symbols, or modern Unicode!
Q2
Why does InnoDB REPEATABLE READ (default isolation level) use Gap Locks—and how can INSERT statements deadlock under concurrent empty lookups?
To prevent phantom rows during SELECT ... FOR UPDATE, InnoDB places Next-Key / Gap Locks on index ranges even when zero rows match! Concurrent threads holding shared gap locks then upgrading to insert intent locks frequently trigger deadlocks.
Q3
Why does INT(11) in MySQL NOT mean a column stores up to 11 digits, nor restrict numeric max values?
An INT ALWAYS uses 4 bytes (-2.14B to +2.14B). The (11) display-width hint (deprecated in MySQL 8.0.17+) only padded ZEROFILL display output, never storage size or value limits.
Q4
Why is ON DELETE CASCADE dangerous on multi-million-row InnoDB parent tables in production?
Deleting one parent row recursively triggers unbatched row-level locks across every child/grandchild table inside a single giant transaction—locking concurrent users out and ballooning undo logs.
Q5
How does InnoDB's Clustered Primary Key work—and why can using random UUIDv4 strings as Primary Key destroy write throughput?
Every secondary index stores a copy of the Primary Key, and InnoDB inserts rows physically sorted by PK. Random UUIDv4 inserts scatter writes randomly across disk pages (causing frequent B-tree page splits and cache misses) unless ordered (UUID_TO_BIN(..., 1) or AUTO_INCREMENT BIGINT).
Q6
What causes EXPLAIN type = ALL even when an index exists on the column in WHERE?
Common culprits: implicit type mismatch (WHERE phone_varchar = 9876543210 without quotes casts every row!), leading wildcard LIKE '%code', wrapping columns in functions (DATE(created_at) = ...), or low-selectivity columns where optimizer prefers full scan.
Q7
Why does GROUP BY without aggregating non-grouped columns fail in MySQL 8+ (ONLY_FULL_GROUP_BY)?
Older MySQL 5.6 returned arbitrary random row values for ungrouped columns. MySQL 8 enforces SQL standard ONLY_FULL_GROUP_BY so queries declare explicit deterministic aggregates (ANY_VALUE, MAX, GROUP_CONCAT).
Q8
How do UNION and UNION ALL differ in MySQL execution plans?
UNION runs an expensive implicit DISTINCT sort/hash pass across all rows to deduplicate results. Whenever result sets are already mutually exclusive, UNION ALL skips deduplication completely.
Q9
Why does running ALTER TABLE ADD COLUMN directly on a busy 50M-row table stall production—and how does ALGORITHM=INSTANT help in MySQL 8?
Traditional COPY table rebuilds lock writes for minutes or hours. MySQL 8 ALGORITHM=INSTANT updates only metadata dictionary headers in milliseconds for trailing/nullable column additions.
Q10
What is the key difference between HAVING and WHERE regarding query execution and index usage?
WHERE filters individual rows *before* grouping using table indexes, whereas HAVING filters grouped buckets *after* GROUP BY and SUM/COUNT calculations.