howmysqlworks
DESCRIPTION
How MySQL worksTRANSCRIPT
![Page 1: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/1.jpg)
MySQL stuff
![Page 2: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/2.jpg)
About me• Before REA I worked for a hosting company for 4
years • Learnt a lot about MySQL during this period • I started as an OPS engineer at REA and did some
database stuff here • I havent done much MySQL for two years !
• In this period we’ve had • MySQL 5.6 come out • RDS MySQL improvements !
!
![Page 3: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/3.jpg)
Today• High level overview of MySQL • Look inside MySQL server • Talk through how InnoDB performs queries • Schema changes and online schema changes
!!
![Page 4: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/4.jpg)
Background• Second biggest relational database in the world
• Anyone know what the biggest is? !
• Used by many of the big web shops • Facebook for all feed data • Etsy for user & data • Twitter for tweet persistence • … !
• Sun bought MySQL AB in 2008, people freaked out • Oracle bought Sun in 2010, people freaked out • Big improvements over the past few years (5.5 / 5.6) !
![Page 5: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/5.jpg)
How it works
mysqld
mysql client tcp:3306
filesocket
ServerClient
libmysql
mysql libORM
host$ mysqlhost$ mysqld_safe!host$ mysqld
![Page 6: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/6.jpg)
Big features• Pluggable storage engines is massive flexibility
• You can use a different storage engine per table !!
• Common storage engines • InnoDB - ACID compliant store • MyISAM - one of the original storage engines -
avoid • Lots and lots of others
!
![Page 7: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/7.jpg)
Inside mysqld
mysqld
storage engine(s) MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
Getting the query and responding
bits and bytes stuff
API
![Page 8: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/8.jpg)
Inside mysqld
mysqld
storage engine(s) MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
API
![Page 9: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/9.jpg)
Inside mysqld
mysqld
storage engine(s) MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
Parse query and convert to SE
API calls.
API
![Page 10: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/10.jpg)
Inside mysqld
mysqld
Storage engines(s)
tcp:3306
filesocket
API
query cache
binary logjoin / sort buffers
Binary Log for replication Buffers: Kinda how much batching to storage API
to save cost
![Page 11: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/11.jpg)
The bad parts - binary log
mysqld
tcp:3306
filesocket
query cache
binary logjoin / sort buffers
Because you can mix and match storage engines,
replicating state has to be done at the lowest
common denominator
Innodb Table 1
MyISAM Table 2
![Page 12: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/12.jpg)
The bad parts - binary log
mysqld
Innodb Table 1
tcp:3306
filesocket
query cache
binary logjoin / sort buffers
Highly concurrent InnoDB needs its queries, serialized down
to replicate to slave
MyISAM Table 2
![Page 13: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/13.jpg)
Compare to other DBs
DB server
tcp:x
filesocket?
performance knobs
transaction log
![Page 14: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/14.jpg)
The bad parts - query cache
mysqld
Innodb Table 1
tcp:3306
filesocket
query cache
binary logjoin / sort buffers
Can only work on an entire table level &
uses LRUMyISAM Table 2
![Page 15: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/15.jpg)
The bad parts - query cache
mysqld
Innodb Table 1
tcp:3306
filesocket
query cache
binary logjoin / sort buffers
All ‘update/insert/delete’ blocks all transactions to ensure correct state.
It actually slows !things down
MyISAM Table 2
![Page 16: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/16.jpg)
Inside mysqld
mysqld
storage engine(s) MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
API
Where 10%* of !the work is done
Where 90% !of the work !
is done
*Finger in the air calculation
![Page 17: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/17.jpg)
Summary• Turn off query cache! It is hurting you! • Binary log is a necessary evil for replication • Dont play with the performance knobs (sort buffer /
join buffer / etc) • Turning the 10% - Focus on the 90%
• Use InnoDB for all the tables (unless they’re system tables) !!
• So…lets look at the 90% !
!
![Page 18: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/18.jpg)
InnoDB
mysqld
InnoDB
tcp:3306
filesocket
API
![Page 19: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/19.jpg)
Unknown gems
mysqld
InnoDB
tcp:3306
filesocket
API
handlersocket/ memcache
Innodb
![Page 20: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/20.jpg)
Unknown gems
mysqld
InnoDB
tcp:3306
filesocket
API
handlersocket/ memcache
Innodb
Memcache API that talks directly to InnoDB !Removes the SQL layer and is just K/V !Google: handlersocket memcache InnoDB
![Page 21: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/21.jpg)
Key parts of InnoDB
Innodb
API
![Page 22: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/22.jpg)
Key parts of InnoDB
Table space (whats on disk)
redo log
Innodb bufferpool
memory!
ib_log1!ib_log2!
sometable.ibd!ib_data!
![Page 23: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/23.jpg)
Key parts of InnoDB
Table space
redo log
bufferpool
• Each block is a page • Just think of it as a row with some extra stuff like
version number • InnoDB is ACID meaning each connection has to
have its own view of the world!• Extra metadata at the top about where everything is
![Page 24: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/24.jpg)
Key parts of InnoDB
Table space
redo log
bufferpool
• Black is the base metadata
![Page 25: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/25.jpg)
What is bufferpool
Table space
redo log
bufferpool
• In memory version of hot tablespace pages
![Page 26: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/26.jpg)
What is redo log
Table space
redo log
bufferpool
• An append only log file of changes
![Page 27: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/27.jpg)
What is table space
Table space
redo log
bufferpool
• The raw files - but it may not be always up-to-date
![Page 28: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/28.jpg)
Lets run some queries
Table space
redo log
bufferpool
• First - lets fill up our database with data
![Page 29: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/29.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
![Page 30: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/30.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
mysqld parses the query and sends !API calls to InnoDB
![Page 31: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/31.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Is red in bufferpool?
![Page 32: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/32.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Load red into buffer pool
perform random !read disk activity!At this point, the time to respond!
is dependent on disk speed!
![Page 33: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/33.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Respond to API calls to mysqld
![Page 34: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/34.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Parse results !second pass sort if necessary !
return to client
![Page 35: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/35.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red; #again
![Page 36: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/36.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
mysqld parses the query and sends !API calls to InnoDB
![Page 37: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/37.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Is red in bufferpool? - yes
![Page 38: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/38.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Respond to API calls to mysqld
![Page 39: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/39.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Parse results !second pass sort if necessary !
return to client
![Page 40: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/40.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from brown;
What if bufferpool is full?
![Page 41: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/41.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from blue;
Assume metadata knows page requirements!LRU on the bufferpool to find space and evict
![Page 42: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/42.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from blue;
!Load in blue as before and return
![Page 43: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/43.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!Is page in bufferpool? yes
![Page 44: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/44.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!Update the page in bufferpool and increment !page version number
![Page 45: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/45.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!Write the new page to the redo log!
what tablespace is up to!
![Page 46: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/46.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!Update metadata telling it that this is the !new state of the page!
perform sequential !write disk activity to redo log!
This is pretty fast!
what tablespace is up to!
![Page 47: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/47.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!Send the OK back to mysqld!
what tablespace is up to!
![Page 48: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/48.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!At sometime in the near future, do a semi sequential !parse changes and update the tablespace
what tablespace is up to! semi sequential write!Not that bad !
!
![Page 49: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/49.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> insert into yellow values (1,2,3,4);
!Is space in bufferpool?!
![Page 50: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/50.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> insert into yellow values (1,2,3,4);
!Is adjacent pages in bufferpool?!
Random read !(but not too big)
![Page 51: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/51.jpg)
Lets run some queries
Table space
redo log
bufferpool
• mysql> insert into yellow values (1,2,3,4);
!Send OK back to client!
![Page 52: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/52.jpg)
Key take aways
Table space
redo log
bufferpool
• Cold databases are slow! • bufferpool is empty and everything requires random disk
reads • The bigger the buffer pool you have, the quicker you will be!
(NUMBER 1 factor on performance!)!• Redo log is the second slowest part
• we can tune this
innodb_flush_logs_at_trx_commit=1
innodb_buffer_pool_size= ~80% memory!
![Page 53: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/53.jpg)
Schema changes• Everyone hates them
• They are not transactional • They are blocking (well most)
• How do they work? !
![Page 54: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/54.jpg)
Remember this?
mysqld
Storage engines(s)
tcp:3306
filesocket
API
query cache
binary logjoin / sort buffers
![Page 55: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/55.jpg)
Lets add a few more
Storage engines(s)
tcp:3306
filesocket
API
table meta data
binary logTable triggers
functions / procedures
![Page 56: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/56.jpg)
mysqld
tcp:3306
filesocket
mytbl
Schema changes
mytbl meta
![Page 57: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/57.jpg)
mytbl
mysql> CREATE TABLE mytbl
(a INT, b CHAR (20), INDEX (a)) ENGINE=InnoDB;
Schema changes
![Page 58: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/58.jpg)
mytbl
Schema changesmysql> ALTER TABLE mytbl
ADD COLUMN age INT;
![Page 59: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/59.jpg)
mytbl
Schema changesmysql> ALTER TABLE mytbl
ADD COLUMN age INT;
!Wait for any open transactions to close and then !lock access to the table!
block
![Page 60: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/60.jpg)
mytbl
Schema changesmysql> ALTER TABLE mytbl
ADD COLUMN age INT;
!Create a new ‘hidden’ table with the new schema!
block
.mytbl
![Page 61: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/61.jpg)
mytbl
Schema changesmysql> ALTER TABLE mytbl
ADD COLUMN age INT;
!Do an internal ‘mysqldump’ / ‘mysqlrestore’!
block
.mytbl
![Page 62: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/62.jpg)
mytbl
Schema changesmysql> ALTER TABLE mytbl
ADD COLUMN age INT;
!Do a switch-a-roo!
block
.mytbl
![Page 63: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/63.jpg)
Schema changesmysql> ALTER TABLE mytbl
ADD COLUMN age INT;
!Unblock and send OK back to client!
mytbl
![Page 64: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/64.jpg)
Online schema changes• Some changes can be done without ‘locking’
• Column additions • Index additions !
• Any removal cannot be done online • Unless you do it yourself
!
![Page 65: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/65.jpg)
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
![Page 66: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/66.jpg)
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER…
pt-online-schema-change soundclouds lhm etc
![Page 67: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/67.jpg)
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
!Creates another table with the updated schema in the client!
![Page 68: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/68.jpg)
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
!Creates a set of triggers on the main table!
triggers
![Page 69: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/69.jpg)
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
!selects the entire table (in batches) and inserts into the new table!!!This can take a long time!
triggers
![Page 70: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/70.jpg)
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
triggersclient
mysql> select
!Whilst the new table is being built, selects still go to the old table!
![Page 71: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/71.jpg)
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
triggersclient
mysql> UPDATE
!Updates cause the trigger to fire which updates the new table being built. (Inserts the row if its still hasn't been copied)!!Deletes happen the same way!
![Page 72: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/72.jpg)
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
triggersclient
mysql> INSERT
!Inserts also happen the same way
![Page 73: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/73.jpg)
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
triggers
!Eventually the table population finishes and a ‘RENAME table’ action is performed (which is quick)
![Page 74: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/74.jpg)
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… .mytbl meta
.mytbl
triggers
!Eventually the table population finishes. This is the only ‘blocking’ time
block block
![Page 75: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/75.jpg)
mytbl
Online schema changes 5.1/5.5
mytbl meta
clientmysql> ALTER… !
The schema change tool finishes
![Page 76: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/76.jpg)
Online schema changes in 5.6• All that ‘switch-a-roo’ logic is now within mysqld itself !
![Page 77: Howmysqlworks](https://reader034.vdocuments.site/reader034/viewer/2022051322/540d81838d7f728d7e8b4995/html5/thumbnails/77.jpg)
Summary about schema changes• You ‘double your IO’ when you’re online schema
changes! • Binary log is outside of this - so watch out for your
slaves table locking if you don't use the right flags !
!