SlideShare a Scribd company logo
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

PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance Tuning
Maven Logix
 
Using all of the high availability options in MariaDB
Using all of the high availability options in MariaDBUsing all of the high availability options in MariaDB
Using all of the high availability options in MariaDB
MariaDB plc
 
MySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA ToolMySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA Tool
Miguel Araújo
 
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion RecordsScylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
ScyllaDB
 
how-to-become-a-mysql-dba.pdf
how-to-become-a-mysql-dba.pdfhow-to-become-a-mysql-dba.pdf
how-to-become-a-mysql-dba.pdf
ALI ANWAR, OCP®
 
Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replication
mysqlops
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability Methods
Mydbops
 
MariaDB MaxScale: an Intelligent Database Proxy
MariaDB MaxScale: an Intelligent Database ProxyMariaDB MaxScale: an Intelligent Database Proxy
MariaDB MaxScale: an Intelligent Database Proxy
Markus Mäkelä
 
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
Altinity Ltd
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScale
MariaDB plc
 
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Simplify CDC Pipeline with Spark Streaming SQL and Delta LakeSimplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Databricks
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
Sveta Smirnova
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
Frederic Descamps
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software Test
I Goo Lee
 
Click-Through Example for Flink’s KafkaConsumer Checkpointing
Click-Through Example for Flink’s KafkaConsumer CheckpointingClick-Through Example for Flink’s KafkaConsumer Checkpointing
Click-Through Example for Flink’s KafkaConsumer Checkpointing
Robert Metzger
 
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin KnaufWebinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Ververica
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
Derek Downey
 
What is new in MariaDB 10.6?
What is new in MariaDB 10.6?What is new in MariaDB 10.6?
What is new in MariaDB 10.6?
Mydbops
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
Mydbops
 
MySQL Basics
MySQL BasicsMySQL Basics
MySQL Basics
mysql content
 

What's hot (20)

PostGreSQL Performance Tuning
PostGreSQL Performance TuningPostGreSQL Performance Tuning
PostGreSQL Performance Tuning
 
Using all of the high availability options in MariaDB
Using all of the high availability options in MariaDBUsing all of the high availability options in MariaDB
Using all of the high availability options in MariaDB
 
MySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA ToolMySQL Shell - The Best MySQL DBA Tool
MySQL Shell - The Best MySQL DBA Tool
 
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion RecordsScylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
Scylla Summit 2022: How to Migrate a Counter Table for 68 Billion Records
 
how-to-become-a-mysql-dba.pdf
how-to-become-a-mysql-dba.pdfhow-to-become-a-mysql-dba.pdf
how-to-become-a-mysql-dba.pdf
 
Percona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replicationPercona Live 2012PPT: introduction-to-mysql-replication
Percona Live 2012PPT: introduction-to-mysql-replication
 
PostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability MethodsPostgreSQL Replication High Availability Methods
PostgreSQL Replication High Availability Methods
 
MariaDB MaxScale: an Intelligent Database Proxy
MariaDB MaxScale: an Intelligent Database ProxyMariaDB MaxScale: an Intelligent Database Proxy
MariaDB MaxScale: an Intelligent Database Proxy
 
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, CloudflareClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
ClickHouse Mark Cache, by Mik Kocikowski, Cloudflare
 
MariaDB MaxScale
MariaDB MaxScaleMariaDB MaxScale
MariaDB MaxScale
 
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Simplify CDC Pipeline with Spark Streaming SQL and Delta LakeSimplify CDC Pipeline with Spark Streaming SQL and Delta Lake
Simplify CDC Pipeline with Spark Streaming SQL and Delta Lake
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
 
Open Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and HistogramsOpen Source 101 2022 - MySQL Indexes and Histograms
Open Source 101 2022 - MySQL Indexes and Histograms
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software Test
 
Click-Through Example for Flink’s KafkaConsumer Checkpointing
Click-Through Example for Flink’s KafkaConsumer CheckpointingClick-Through Example for Flink’s KafkaConsumer Checkpointing
Click-Through Example for Flink’s KafkaConsumer Checkpointing
 
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin KnaufWebinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
 
What is new in MariaDB 10.6?
What is new in MariaDB 10.6?What is new in MariaDB 10.6?
What is new in MariaDB 10.6?
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
MySQL Basics
MySQL BasicsMySQL Basics
MySQL Basics
 

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 Server
MariaDB 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 surprises
Nelson Calero
 
6.3 Mload.pdf
6.3 Mload.pdf6.3 Mload.pdf
6.3 Mload.pdf
ssuser8b6c85
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
paulguerin
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
metsarin
 
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
nishantdavid9
 
SQL Server 2008 Performance Enhancements
SQL Server 2008 Performance EnhancementsSQL Server 2008 Performance Enhancements
SQL Server 2008 Performance Enhancements
infusiondev
 
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
Mazenetsolution
 
Les09.ppt
Les09.pptLes09.ppt
Stored procedure
Stored procedureStored procedure
Stored procedure
Stored procedureStored procedure
Sql coding-standard-sqlserver
Sql coding-standard-sqlserverSql coding-standard-sqlserver
Sql coding-standard-sqlserver
lochaaaa
 
Etl2
Etl2Etl2
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
MariaDB plc
 
My sql.ppt
My sql.pptMy sql.ppt
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101
Federico Razzoli
 
Les10[1]Creating and Managing Tables
Les10[1]Creating and Managing TablesLes10[1]Creating and Managing Tables
Les10[1]Creating and Managing Tables
siavosh kaviani
 
Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentation
oracle documents
 
PostgreSQL 9.5 Features
PostgreSQL 9.5 FeaturesPostgreSQL 9.5 Features
PostgreSQL 9.5 Features
Saiful
 

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 Guidelines
Morgan Tocker
 
My First 90 days with Vitess
My First 90 days with VitessMy First 90 days with Vitess
My First 90 days with Vitess
Morgan Tocker
 
FOSDEM MySQL and Friends Devroom
FOSDEM MySQL and Friends DevroomFOSDEM MySQL and Friends Devroom
FOSDEM MySQL and Friends Devroom
Morgan Tocker
 
Introducing TiDB - Percona Live Frankfurt
Introducing TiDB - Percona Live FrankfurtIntroducing TiDB - Percona Live Frankfurt
Introducing TiDB - Percona Live Frankfurt
Morgan Tocker
 
TiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup GroupTiDB Introduction - Boston MySQL Meetup Group
TiDB Introduction - Boston MySQL Meetup Group
Morgan Tocker
 
TiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL MeetupTiDB Introduction - San Francisco MySQL Meetup
TiDB Introduction - San Francisco MySQL Meetup
Morgan Tocker
 
TiDB Introduction
TiDB IntroductionTiDB Introduction
TiDB Introduction
Morgan Tocker
 
MySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer GuideMySQL 8.0 Optimizer Guide
MySQL 8.0 Optimizer Guide
Morgan Tocker
 
MySQL Server Defaults
MySQL Server DefaultsMySQL Server Defaults
MySQL Server Defaults
Morgan Tocker
 
MySQL Cloud Service Deep Dive
MySQL Cloud Service Deep DiveMySQL Cloud Service Deep Dive
MySQL Cloud Service Deep Dive
Morgan Tocker
 
MySQL 5.7 + JSON
MySQL 5.7 + JSONMySQL 5.7 + JSON
MySQL 5.7 + JSON
Morgan Tocker
 
Using MySQL in Automated Testing
Using MySQL in Automated TestingUsing MySQL in Automated Testing
Using MySQL in Automated Testing
Morgan Tocker
 
Upcoming changes in MySQL 5.7
Upcoming changes in MySQL 5.7Upcoming changes in MySQL 5.7
Upcoming changes in MySQL 5.7
Morgan Tocker
 
MySQL Query Optimization
MySQL Query OptimizationMySQL Query Optimization
MySQL Query Optimization
Morgan Tocker
 
MySQL Performance Metrics that Matter
MySQL Performance Metrics that MatterMySQL Performance Metrics that Matter
MySQL Performance Metrics that Matter
Morgan Tocker
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux Sysadmins
Morgan 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 Data
Morgan Tocker
 
MySQL NoSQL APIs
MySQL NoSQL APIsMySQL NoSQL APIs
MySQL NoSQL APIs
Morgan Tocker
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server Changes
Morgan 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 Improvements
Morgan 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

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 

Recently uploaded (20)

Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 

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