Skip to main content
InterviewHubPRO
Section Overview
Q26

Question 26 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

52%
MySQL & InnoDB (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

How do you perform Zero-Downtime Online Schema Changes (Online DDL vs gh-ost / pt-online-schema-change)?

senior LevelForms

In Simple Words: Altering a 500 GB table (ALTER TABLE orders ADD COLUMN ...) locks the table or consumes massive disk I/O:

  • InnoDB Online DDL: MySQL 8.0 supports instant column addition (ALGORITHM=INSTANT), modifying only metadata in milliseconds.
  • gh-ost / pt-online-schema-change (For complex alters):
    1. Creates a shadow table with the new schema.
    2. Copies historical data in small chunked batches.
    3. Uses binlog stream capture (gh-ost) or triggers (pt-osc) to replicate live ongoing writes to the shadow table.
    4. Swaps tables atomically using RENAME TABLE orders TO orders_old, orders_new TO orders;.