SlideShare a Scribd company logo
1 of 21
Download to read offline
Spirit
Online Schema
Change Utility
for MySQL 8.0
1
Morgan Tocker
MySQL Belgian Days 2024
Agenda.
1. State of DDL
2. How Spirit works
3. Optimizations
4. Feature requests for MySQL DDL
2
ALTER TABLE t1 _
3
* Simplified
ADD COLUMN, DROP COLUMN, RENAME COLUMN,
CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE
INSTANT
INPLACE
COPY
DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP
PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL,
INCREASE VARCHAR (same ptr len)
CHANGE DATA TYPE, ADD PRIMARY KEY,
DROP PRIMARY KEY, CHANGE CHARACTER SET
INSTANT
■ New to MySQL 8.0
■ Works 99% as described
■ Nuanced exceptions:
■ Max 64 instant ADD/DROP
columns before a fully copy
■ Compressed tables
■ Temporary tables
■ Tables with FULLTEXT
indexes
4
Production
Safe
Assert with:
ALTER TABLE t1 ADD newcol
INT, ALGORITHM=INSTANT;
INPLACE
Time varies between operations
Blocks InnoDB Purge
5
Production
Safe
Statement Algorithm Time
Drop Index DROP INDEX b INPLACE 0.00s
Extend Varchar (same ptr len) MODIFY b VARCHAR(61) INPLACE 0.00s
Add Column ADD COLUMN d INT INSTANT 0.08s
Add Index ADD INDEX(b) INPLACE 8.49s
Extend Varchar (larger ptr len) MODIFY b VARCHAR(70) COPY 16.23s
Set NULL MODIFY b VARCHAR(60) NULL INPLACE 18.74s
Set NOT NULL MODIFY b VARCHAR(60) NOT NULL INPLACE 18.83s
NULL ALTER ENGINE=InnoDB COPY 18.88s
COPY
■ Rebuilds the whole table
■ Some operations are also
blocking:
“Permits Concurrent DML: No”
ALTER TABLE t1
ALGORITHM=copy, LOCK=none;
6
Production
Safe
How do you make schema changes then?
7
1. Once upon a time:
replication flipping
(aka blue green)
■ Not safe with Row-based
Replication
2. Use an external tool:
■ Pt-online-schema-change
■ Gh-ost
■ Spirit (new!)
Agenda.
1. State of DDL
2. How Spirit works
3. Optimizations
4. Feature requests for MySQL DDL
8
Basic Algorithm
9
■ Copy table definition to a
new table
■ Alter the new table
■ Start subscribing to
replication changes
■ Copy rows from origin to
new
■ Apply changes from
replication
■ Cutover
Nuanced Algorithm
10
■ Attempt INSTANT DDL
■ Parse DDL and apply
INPLACE if only
DROP/RENAME index
■ Copy table definition to a
new table
■ Alter the new table
■ Start subscribing to
replication changes
■ Copy rows from origin to
new
■ Apply changes from
replication
■ Checksum
■ Cutover
Agenda.
1. State of DDL
2. How Spirit works
3. Optimizations
4. Feature requests for MySQL DDL
11
Limitations (for some)
12
■ Only MySQL 8.0
■ Must have a Primary Key
■ No FOREIGN KEY support
■ No RENAME column
■ No Triggers
■ No lossy conversions
■ Replication Throttling to
minimum of 10s fidelity
Dynamic Chunking
Optimizations: Copying Rows
13
Parallel Copy
Batching based
on time not rows
(default: 500ms)
Copied in N
threads
(default: 4)
Optimizations: Apply Changes
14
■ Delta Map / Parallel Apply
■ Requires memory comparable
Primary Key
■ Key Above Watermark
■ Currently requires
auto-increment Primary Key
Features: Checkpointing
15
■ Every ~1m save point the
copy/apply has safely
completed
■ Allows for resume of
changes
Agenda.
1. State of DDL
2. How Spirit works
3. Optimizations
4. Feature requests for MySQL DDL
16
BUG #113355
17
ADD COLUMN, DROP COLUMN, RENAME COLUMN,
CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE
INSTANT
INPLACE
COPY
DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP
PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL,
INCREASE VARCHAR (same ptr len)
CHANGE DATA TYPE, ADD PRIMARY KEY,
DROP PRIMARY KEY, CHANGE CHARACTER SET
DROP/RENAME INDEX as INSTANT
BUG #113476
18
ADD COLUMN, DROP COLUMN, RENAME COLUMN,
CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE
INSTANT
INPLACE
COPY
DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP
PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL,
INCREASE VARCHAR (same ptr len)
CHANGE DATA TYPE, ADD PRIMARY KEY,
DROP PRIMARY KEY, CHANGE CHARACTER SET
Long running INPLACE grows HLL
BUG #113355
19
ADD COLUMN, DROP COLUMN, RENAME COLUMN,
CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE
INSTANT
INPLACE
COPY
DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP
PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL,
INCREASE VARCHAR (same ptr len)
CHANGE DATA TYPE, ADD PRIMARY KEY,
DROP PRIMARY KEY, CHANGE CHARACTER SET
Support INSTANT for some change type
The Potential Future
20
ADD COLUMN, DROP COLUMN, DROP INDEX, CHANGE DATA TYPE
(expansion), RENAME COLUMN, CHANGE DEFAULT VALUE, CHANGE
ENUM/SET
INSTANT
INPLACE
SPIRIT
ADD INDEX
CHANGE DATA TYPE (other), CHANGE NULL/NOT NULL
vs OUR MOST COMMON DDLs
Conclusion
Instant DDL is awesome
Large schema changes #1
blocker to larger databases
Spirit is symbiotic
It attempts MySQL DDL
first, falls back as required
As more changes become
instant, Spirit will take
advantage
21
github.com/cashapp/spirit
Apache 2.0 License

More Related Content

What's hot

MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용I Goo Lee
 
ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)Mydbops
 
Vertica 7.0 Architecture Overview
Vertica 7.0 Architecture OverviewVertica 7.0 Architecture Overview
Vertica 7.0 Architecture OverviewAndrey Karpov
 
MMUG18 - MySQL Failover and Orchestrator
MMUG18 - MySQL Failover and OrchestratorMMUG18 - MySQL Failover and Orchestrator
MMUG18 - MySQL Failover and OrchestratorSimon J Mudd
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joinsMudasir Syed
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestratorYoungHeon (Roy) Kim
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18Derek Downey
 
How to set up orchestrator to manage thousands of MySQL servers
How to set up orchestrator to manage thousands of MySQL serversHow to set up orchestrator to manage thousands of MySQL servers
How to set up orchestrator to manage thousands of MySQL serversSimon J Mudd
 
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScaleThe Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScaleColin Charles
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability Mydbops
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewRené Cannaò
 
MariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseMariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseSeveralnines
 
JSON improvements in MySQL 8.0
JSON improvements in MySQL 8.0JSON improvements in MySQL 8.0
JSON improvements in MySQL 8.0Mydbops
 
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)Miguel Araújo
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance TuningMaven Logix
 
MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개rockplace
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpen Gurukul
 

What's hot (20)

MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용MySQL 상태 메시지 분석 및 활용
MySQL 상태 메시지 분석 및 활용
 
ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)ProxySQL High Availability (Clustering)
ProxySQL High Availability (Clustering)
 
Vertica 7.0 Architecture Overview
Vertica 7.0 Architecture OverviewVertica 7.0 Architecture Overview
Vertica 7.0 Architecture Overview
 
Percona toolkit
Percona toolkitPercona toolkit
Percona toolkit
 
Recursive Query Throwdown
Recursive Query ThrowdownRecursive Query Throwdown
Recursive Query Throwdown
 
MMUG18 - MySQL Failover and Orchestrator
MMUG18 - MySQL Failover and OrchestratorMMUG18 - MySQL Failover and Orchestrator
MMUG18 - MySQL Failover and Orchestrator
 
PHP mysql Mysql joins
PHP mysql  Mysql joinsPHP mysql  Mysql joins
PHP mysql Mysql joins
 
My sql failover test using orchestrator
My sql failover test  using orchestratorMy sql failover test  using orchestrator
My sql failover test using orchestrator
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
 
How to set up orchestrator to manage thousands of MySQL servers
How to set up orchestrator to manage thousands of MySQL serversHow to set up orchestrator to manage thousands of MySQL servers
How to set up orchestrator to manage thousands of MySQL servers
 
InnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick FiguresInnoDB Locking Explained with Stick Figures
InnoDB Locking Explained with Stick Figures
 
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScaleThe Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
The Proxy Wars - MySQL Router, ProxySQL, MariaDB MaxScale
 
Galera cluster for high availability
Galera cluster for high availability Galera cluster for high availability
Galera cluster for high availability
 
ProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management OverviewProxySQL High Avalability and Configuration Management Overview
ProxySQL High Avalability and Configuration Management Overview
 
MariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash CourseMariaDB Performance Tuning Crash Course
MariaDB Performance Tuning Crash Course
 
JSON improvements in MySQL 8.0
JSON improvements in MySQL 8.0JSON improvements in MySQL 8.0
JSON improvements in MySQL 8.0
 
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
MySQL Router - Explore The Secrets (MySQL Belgian Days 2024)
 
PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance Tuning
 
MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개
 
OpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQLOpenGurukul : Database : PostgreSQL
OpenGurukul : Database : PostgreSQL
 

Similar to Introducing Spirit - Online Schema Change

ALTER TABLE Improvements in MariaDB Server
ALTER TABLE Improvements in MariaDB ServerALTER TABLE Improvements in MariaDB Server
ALTER TABLE Improvements in MariaDB ServerMariaDB plc
 
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Valerii Kravchuk
 
Redefining tables online without surprises
Redefining tables online without surprisesRedefining tables online without surprises
Redefining tables online without surprisesNelson Calero
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
Stored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlStored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlnishantdavid9
 
SQL Server 2008 Performance Enhancements
SQL Server 2008 Performance EnhancementsSQL Server 2008 Performance Enhancements
SQL Server 2008 Performance Enhancementsinfusiondev
 
Oracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionOracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionMazenetsolution
 
Sql coding-standard-sqlserver
Sql coding-standard-sqlserverSql coding-standard-sqlserver
Sql coding-standard-sqlserverlochaaaa
 
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-KompatibilitätMariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-KompatibilitätMariaDB plc
 
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101Federico Razzoli
 
Les10[1]Creating and Managing Tables
Les10[1]Creating and Managing TablesLes10[1]Creating and Managing Tables
Les10[1]Creating and Managing Tablessiavosh kaviani
 
PostgreSQL 9.5 Features
PostgreSQL 9.5 FeaturesPostgreSQL 9.5 Features
PostgreSQL 9.5 FeaturesSaiful
 

Similar to Introducing Spirit - Online Schema Change (20)

ALTER TABLE Improvements in MariaDB Server
ALTER TABLE Improvements in MariaDB ServerALTER TABLE Improvements in MariaDB Server
ALTER TABLE Improvements in MariaDB Server
 
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
 
Redefining tables online without surprises
Redefining tables online without surprisesRedefining tables online without surprises
Redefining tables online without surprises
 
6.3 Mload.pdf
6.3 Mload.pdf6.3 Mload.pdf
6.3 Mload.pdf
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Stored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sqlStored procedure tuning and optimization t sql
Stored procedure tuning and optimization t sql
 
SQL Server 2008 Performance Enhancements
SQL Server 2008 Performance EnhancementsSQL Server 2008 Performance Enhancements
SQL Server 2008 Performance Enhancements
 
Oracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solutionOracle- Introduction to Sql commands- Mazenet solution
Oracle- Introduction to Sql commands- Mazenet solution
 
Les09.ppt
Les09.pptLes09.ppt
Les09.ppt
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Sql coding-standard-sqlserver
Sql coding-standard-sqlserverSql coding-standard-sqlserver
Sql coding-standard-sqlserver
 
Etl2
Etl2Etl2
Etl2
 
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-KompatibilitätMariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101
 
Les10[1]Creating and Managing Tables
Les10[1]Creating and Managing TablesLes10[1]Creating and Managing Tables
Les10[1]Creating and Managing Tables
 
Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentation
 
PostgreSQL 9.5 Features
PostgreSQL 9.5 FeaturesPostgreSQL 9.5 Features
PostgreSQL 9.5 Features
 

More from Morgan Tocker

MySQL Usability Guidelines
MySQL Usability GuidelinesMySQL Usability Guidelines
MySQL Usability GuidelinesMorgan Tocker
 
My First 90 days with Vitess
My First 90 days with VitessMy First 90 days with Vitess
My First 90 days with VitessMorgan Tocker
 
FOSDEM MySQL and Friends Devroom
FOSDEM MySQL and Friends DevroomFOSDEM MySQL and Friends Devroom
FOSDEM MySQL and Friends DevroomMorgan Tocker
 
Introducing TiDB - Percona Live Frankfurt
Introducing TiDB - Percona Live FrankfurtIntroducing TiDB - Percona Live Frankfurt
Introducing TiDB - Percona Live FrankfurtMorgan Tocker
 
TiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup GroupTiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup GroupMorgan Tocker
 
TiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL MeetupTiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL MeetupMorgan Tocker
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMorgan Tocker
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server DefaultsMorgan Tocker
 
MySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMorgan Tocker
 
Using MySQL in Automated Testing
Using MySQL in Automated TestingUsing MySQL in Automated Testing
Using MySQL in Automated TestingMorgan Tocker
 
Upcoming changes in MySQL 5.7
Upcoming changes in MySQL 5.7Upcoming changes in MySQL 5.7
Upcoming changes in MySQL 5.7Morgan Tocker
 
MySQL Query Optimization
MySQL Query OptimizationMySQL Query Optimization
MySQL Query OptimizationMorgan Tocker
 
MySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMorgan Tocker
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux SysadminsMorgan Tocker
 
MySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big DataMySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big DataMorgan Tocker
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMorgan Tocker
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMorgan Tocker
 

More from Morgan Tocker (20)

MySQL Usability Guidelines
MySQL Usability GuidelinesMySQL Usability Guidelines
MySQL Usability Guidelines
 
My First 90 days with Vitess
My First 90 days with VitessMy First 90 days with Vitess
My First 90 days with Vitess
 
FOSDEM MySQL and Friends Devroom
FOSDEM MySQL and Friends DevroomFOSDEM MySQL and Friends Devroom
FOSDEM MySQL and Friends Devroom
 
Introducing TiDB - Percona Live Frankfurt
Introducing TiDB - Percona Live FrankfurtIntroducing TiDB - Percona Live Frankfurt
Introducing TiDB - Percona Live Frankfurt
 
TiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup GroupTiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup Group
 
TiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL MeetupTiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL Meetup
 
TiDB Introduction
TiDB IntroductionTiDB Introduction
TiDB Introduction
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer Guide
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server Defaults
 
MySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMySQL Cloud Service Deep Dive
MySQL Cloud Service Deep Dive
 
MySQL 5.7 + JSON
MySQL 5.7 + JSONMySQL 5.7 + JSON
MySQL 5.7 + JSON
 
Using MySQL in Automated Testing
Using MySQL in Automated TestingUsing MySQL in Automated Testing
Using MySQL in Automated Testing
 
Upcoming changes in MySQL 5.7
Upcoming changes in MySQL 5.7Upcoming changes in MySQL 5.7
Upcoming changes in MySQL 5.7
 
MySQL Query Optimization
MySQL Query OptimizationMySQL Query Optimization
MySQL Query Optimization
 
MySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMySQL Performance Metrics that Matter
MySQL Performance Metrics that Matter
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux Sysadmins
 
MySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big DataMySQL: From Single Instance to Big Data
MySQL: From Single Instance to Big Data
 
MySQL NoSQL APIs
MySQL NoSQL APIsMySQL NoSQL APIs
MySQL NoSQL APIs
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server Changes
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
 

Recently uploaded

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 

Recently uploaded (20)

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 

Introducing Spirit - Online Schema Change

  • 1. Spirit Online Schema Change Utility for MySQL 8.0 1 Morgan Tocker MySQL Belgian Days 2024
  • 2. Agenda. 1. State of DDL 2. How Spirit works 3. Optimizations 4. Feature requests for MySQL DDL 2
  • 3. ALTER TABLE t1 _ 3 * Simplified ADD COLUMN, DROP COLUMN, RENAME COLUMN, CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE INSTANT INPLACE COPY DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL, INCREASE VARCHAR (same ptr len) CHANGE DATA TYPE, ADD PRIMARY KEY, DROP PRIMARY KEY, CHANGE CHARACTER SET
  • 4. INSTANT ■ New to MySQL 8.0 ■ Works 99% as described ■ Nuanced exceptions: ■ Max 64 instant ADD/DROP columns before a fully copy ■ Compressed tables ■ Temporary tables ■ Tables with FULLTEXT indexes 4 Production Safe Assert with: ALTER TABLE t1 ADD newcol INT, ALGORITHM=INSTANT;
  • 5. INPLACE Time varies between operations Blocks InnoDB Purge 5 Production Safe Statement Algorithm Time Drop Index DROP INDEX b INPLACE 0.00s Extend Varchar (same ptr len) MODIFY b VARCHAR(61) INPLACE 0.00s Add Column ADD COLUMN d INT INSTANT 0.08s Add Index ADD INDEX(b) INPLACE 8.49s Extend Varchar (larger ptr len) MODIFY b VARCHAR(70) COPY 16.23s Set NULL MODIFY b VARCHAR(60) NULL INPLACE 18.74s Set NOT NULL MODIFY b VARCHAR(60) NOT NULL INPLACE 18.83s NULL ALTER ENGINE=InnoDB COPY 18.88s
  • 6. COPY ■ Rebuilds the whole table ■ Some operations are also blocking: “Permits Concurrent DML: No” ALTER TABLE t1 ALGORITHM=copy, LOCK=none; 6 Production Safe
  • 7. How do you make schema changes then? 7 1. Once upon a time: replication flipping (aka blue green) ■ Not safe with Row-based Replication 2. Use an external tool: ■ Pt-online-schema-change ■ Gh-ost ■ Spirit (new!)
  • 8. Agenda. 1. State of DDL 2. How Spirit works 3. Optimizations 4. Feature requests for MySQL DDL 8
  • 9. Basic Algorithm 9 ■ Copy table definition to a new table ■ Alter the new table ■ Start subscribing to replication changes ■ Copy rows from origin to new ■ Apply changes from replication ■ Cutover
  • 10. Nuanced Algorithm 10 ■ Attempt INSTANT DDL ■ Parse DDL and apply INPLACE if only DROP/RENAME index ■ Copy table definition to a new table ■ Alter the new table ■ Start subscribing to replication changes ■ Copy rows from origin to new ■ Apply changes from replication ■ Checksum ■ Cutover
  • 11. Agenda. 1. State of DDL 2. How Spirit works 3. Optimizations 4. Feature requests for MySQL DDL 11
  • 12. Limitations (for some) 12 ■ Only MySQL 8.0 ■ Must have a Primary Key ■ No FOREIGN KEY support ■ No RENAME column ■ No Triggers ■ No lossy conversions ■ Replication Throttling to minimum of 10s fidelity
  • 13. Dynamic Chunking Optimizations: Copying Rows 13 Parallel Copy Batching based on time not rows (default: 500ms) Copied in N threads (default: 4)
  • 14. Optimizations: Apply Changes 14 ■ Delta Map / Parallel Apply ■ Requires memory comparable Primary Key ■ Key Above Watermark ■ Currently requires auto-increment Primary Key
  • 15. Features: Checkpointing 15 ■ Every ~1m save point the copy/apply has safely completed ■ Allows for resume of changes
  • 16. Agenda. 1. State of DDL 2. How Spirit works 3. Optimizations 4. Feature requests for MySQL DDL 16
  • 17. BUG #113355 17 ADD COLUMN, DROP COLUMN, RENAME COLUMN, CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE INSTANT INPLACE COPY DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL, INCREASE VARCHAR (same ptr len) CHANGE DATA TYPE, ADD PRIMARY KEY, DROP PRIMARY KEY, CHANGE CHARACTER SET DROP/RENAME INDEX as INSTANT
  • 18. BUG #113476 18 ADD COLUMN, DROP COLUMN, RENAME COLUMN, CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE INSTANT INPLACE COPY DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL, INCREASE VARCHAR (same ptr len) CHANGE DATA TYPE, ADD PRIMARY KEY, DROP PRIMARY KEY, CHANGE CHARACTER SET Long running INPLACE grows HLL
  • 19. BUG #113355 19 ADD COLUMN, DROP COLUMN, RENAME COLUMN, CHANGE DEFAULT VALUE, CHANGE ENUM/SET, RENAME TABLE INSTANT INPLACE COPY DROP INDEX, RENAME INDEX, ADD INDEX, ADD PARTITION, DROP PARTITION, TRUNCATE PARTITION, CHANGE NULL/NOT NULL, INCREASE VARCHAR (same ptr len) CHANGE DATA TYPE, ADD PRIMARY KEY, DROP PRIMARY KEY, CHANGE CHARACTER SET Support INSTANT for some change type
  • 20. The Potential Future 20 ADD COLUMN, DROP COLUMN, DROP INDEX, CHANGE DATA TYPE (expansion), RENAME COLUMN, CHANGE DEFAULT VALUE, CHANGE ENUM/SET INSTANT INPLACE SPIRIT ADD INDEX CHANGE DATA TYPE (other), CHANGE NULL/NOT NULL vs OUR MOST COMMON DDLs
  • 21. Conclusion Instant DDL is awesome Large schema changes #1 blocker to larger databases Spirit is symbiotic It attempts MySQL DDL first, falls back as required As more changes become instant, Spirit will take advantage 21 github.com/cashapp/spirit Apache 2.0 License