SlideShare une entreprise Scribd logo
1  sur  77
Télécharger pour lire hors ligne
MySQL stuff
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
!
!
Today
• High level overview of MySQL
• Look inside MySQL server
• Talk through how InnoDB performs queries
• Schema changes and online schema changes
!
!
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)
!
How it works
mysqld
mysql client tcp:3306
filesocket
ServerClient
libmysql
mysql lib
ORM
host$ mysql
host$ mysqld_safe!
host$ mysqld
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
!
Inside mysqld
mysqld
storage engine(s)
MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
Getting the query
and responding
bits and
bytes stuff
API
Inside mysqld
mysqld
storage engine(s)
MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
API
Inside mysqld
mysqld
storage engine(s)
MyISAM / InnoDB / Memory / etc
tcp:3306
filesocket
Parse query and
convert to SE
API calls.
API
Inside mysqld
mysqld
Storage engines(s)
tcp:3306
filesocket
API
query cache
binary log
join / sort buffers
Binary Log for replication
Buffers: Kinda how much
batching to storage API
to save cost
The bad parts - binary log
mysqld
tcp:3306
filesocket
query cache
binary log
join / 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
The bad parts - binary log
mysqld
Innodb
Table 1
tcp:3306
filesocket
query cache
binary log
join / sort buffers
Highly concurrent InnoDB
needs its queries,
serialized down
to replicate to slave
MyISAM
Table 2
Compare to other DBs
DB server
tcp:x
filesocket?
performance
knobs
transaction
log
The bad parts - query cache
mysqld
Innodb
Table 1
tcp:3306
filesocket
query cache
binary log
join / sort buffers
Can only work on an
entire table level &
uses LRU
MyISAM
Table 2
The bad parts - query cache
mysqld
Innodb
Table 1
tcp:3306
filesocket
query cache
binary log
join / sort buffers
All ‘update/insert/delete’
blocks all transactions
to ensure correct state.
It actually slows !
things down
MyISAM
Table 2
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
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%
!
!
InnoDB
mysqld
InnoDB
tcp:3306
filesocket
API
Unknown gems
mysqld
InnoDB
tcp:3306
filesocket
API
handlersocket/
memcache
Innodb
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
Key parts of InnoDB
Innodb
API
Key parts of InnoDB
Table space
(whats on disk)
redo log
Innodb
bufferpool
memory!
ib_log1!
ib_log2!
sometable.ibd!
ib_data!
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
Key parts of InnoDB
Table space
redo log
bufferpool
• Black is the base metadata
What is bufferpool
Table space
redo log
bufferpool
• In memory version of hot tablespace pages
What is redo log
Table space
redo log
bufferpool
• An append only log file of changes
What is table space
Table space
redo log
bufferpool
• The raw files - but it may not be always up-to-date
Lets run some queries
Table space
redo log
bufferpool
• First - lets fill up our database with data
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
mysqld parses the query and sends !
API calls to InnoDB
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Is red in bufferpool?
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!
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Respond to API calls to mysqld
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Parse results !
second pass sort if necessary !
return to client
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red; #again
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
mysqld parses the query and sends !
API calls to InnoDB
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Is red in bufferpool? - yes
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Respond to API calls to mysqld
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from red;
Parse results !
second pass sort if necessary !
return to client
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from brown;
What if bufferpool is full?
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
Lets run some queries
Table space
redo log
bufferpool
• mysql> select * from blue;
!
Load in blue as before and return
Lets run some queries
Table space
redo log
bufferpool
• mysql> update blue set A=B where ID=1;
!
Is page in bufferpool? yes
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
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!
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!
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!
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 !
!
Lets run some queries
Table space
redo log
bufferpool
• mysql> insert into yellow values
(1,2,3,4);
!
Is space in bufferpool?!
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)
Lets run some queries
Table space
redo log
bufferpool
• mysql> insert into yellow values
(1,2,3,4);
!
Send OK back to client!
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!
Schema changes
• Everyone hates them
• They are not transactional
• They are blocking (well most)
• How do they work?
!
Remember this?
mysqld
Storage engines(s)
tcp:3306
filesocket
API
query cache
binary log
join / sort buffers
Lets add a few more
Storage engines(s)
tcp:3306
filesocket
API
table meta data
binary log
Table triggers
functions / procedures
mysqld
tcp:3306
filesocket
mytbl
Schema changes
mytbl meta
mytbl
mysql> CREATE TABLE mytbl 

(a INT, b CHAR (20), INDEX (a)) ENGINE=InnoDB;
Schema changes
mytbl
Schema changes
mysql> ALTER TABLE mytbl 

ADD COLUMN age INT;
mytbl
Schema changes
mysql> ALTER TABLE mytbl 

ADD COLUMN age INT;
!
Wait for any open transactions to close and then !
lock access to the table!
block
mytbl
Schema changes
mysql> ALTER TABLE mytbl 

ADD COLUMN age INT;
!
Create a new ‘hidden’ table with the new schema!
block
.mytbl
mytbl
Schema changes
mysql> ALTER TABLE mytbl 

ADD COLUMN age INT;
!
Do an internal ‘mysqldump’ / ‘mysqlrestore’!
block
.mytbl
mytbl
Schema changes
mysql> ALTER TABLE mytbl 

ADD COLUMN age INT;
!
Do a switch-a-roo!
block
.mytbl
Schema changes
mysql> ALTER TABLE mytbl 

ADD COLUMN age INT;
!
Unblock and send OK back to client!
mytbl
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
!
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER…
pt-online-schema-change
soundclouds lhm
etc
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
!
Creates another
table with the
updated
schema in the
client!
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
!
Creates a set of
triggers on the
main table!
triggers
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
!
selects the
entire table (in
batches) and
inserts into the
new table!
!
!
This can take a
long time!
triggers
mysqld
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
triggers
client
mysql> select
!
Whilst the new
table is being
built, selects
still go to the
old table!
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
triggers
client
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!
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
triggers
client
mysql> INSERT
!
Inserts also
happen the
same way
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
triggers
!
Eventually the
table
population
finishes and a
‘RENAME table’
action is
performed
(which is quick)
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… .mytbl meta
.mytbl
triggers
!
Eventually the
table
population
finishes. This is
the only
‘blocking’ time
block block
mytbl
Online schema changes 5.1/5.5
mytbl meta
client
mysql> ALTER… !
The schema
change tool
finishes
Online schema changes in 5.6
• All that ‘switch-a-roo’ logic is now within mysqld itself
!
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
!
!

Contenu connexe

Tendances

Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data storesTomas Doran
 
Lessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’tLessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’tPGConf APAC
 
High Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance TuningHigh Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance TuningAlbert Chen
 
Low Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesLow Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesTanel Poder
 
HBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsHBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsMichael Stack
 
Online Schema Changes for Maximizing Uptime
 Online Schema Changes for Maximizing Uptime Online Schema Changes for Maximizing Uptime
Online Schema Changes for Maximizing UptimePythian
 
Apache Flink vs Apache Spark - Reproducible experiments on cloud.
Apache Flink vs Apache Spark - Reproducible experiments on cloud.Apache Flink vs Apache Spark - Reproducible experiments on cloud.
Apache Flink vs Apache Spark - Reproducible experiments on cloud.Shelan Perera
 
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...confluent
 
Apache Big Data EU 2015 - Phoenix
Apache Big Data EU 2015 - PhoenixApache Big Data EU 2015 - Phoenix
Apache Big Data EU 2015 - PhoenixNick Dimiduk
 
MySQL5.7 Innodb_enhance_parti_20160317
MySQL5.7 Innodb_enhance_parti_20160317MySQL5.7 Innodb_enhance_parti_20160317
MySQL5.7 Innodb_enhance_parti_20160317Saewoong Lee
 
Training Slides: Basics 103: The Power of Tungsten Connector / Proxy
Training Slides: Basics 103: The Power of Tungsten Connector / ProxyTraining Slides: Basics 103: The Power of Tungsten Connector / Proxy
Training Slides: Basics 103: The Power of Tungsten Connector / ProxyContinuent
 
Presto changes
Presto changesPresto changes
Presto changesN Masahiro
 
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Apex
 
0.5mln packets per second with Erlang
0.5mln packets per second with Erlang0.5mln packets per second with Erlang
0.5mln packets per second with ErlangMaxim Kharchenko
 
From Zero to Hero with Kafka Connect
From Zero to Hero with Kafka ConnectFrom Zero to Hero with Kafka Connect
From Zero to Hero with Kafka ConnectDatabricks
 
Presto - Analytical Database. Overview and use cases.
Presto - Analytical Database. Overview and use cases.Presto - Analytical Database. Overview and use cases.
Presto - Analytical Database. Overview and use cases.Wojciech Biela
 
January 2015 HUG: Apache Flink: Fast and reliable large-scale data processing
January 2015 HUG: Apache Flink:  Fast and reliable large-scale data processingJanuary 2015 HUG: Apache Flink:  Fast and reliable large-scale data processing
January 2015 HUG: Apache Flink: Fast and reliable large-scale data processingYahoo Developer Network
 
Postgres vision 2018: The Promise of zheap
Postgres vision 2018: The Promise of zheapPostgres vision 2018: The Promise of zheap
Postgres vision 2018: The Promise of zheapEDB
 
Building a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and SparkBuilding a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and SparkEvan Chan
 
Postgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to KnowPostgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to KnowEDB
 

Tendances (20)

Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data stores
 
Lessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’tLessons PostgreSQL learned from commercial databases, and didn’t
Lessons PostgreSQL learned from commercial databases, and didn’t
 
High Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance TuningHigh Concurrency Architecture and Laravel Performance Tuning
High Concurrency Architecture and Laravel Performance Tuning
 
Low Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling ExamplesLow Level CPU Performance Profiling Examples
Low Level CPU Performance Profiling Examples
 
HBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbmsHBaseConEast2016: Splice machine open source rdbms
HBaseConEast2016: Splice machine open source rdbms
 
Online Schema Changes for Maximizing Uptime
 Online Schema Changes for Maximizing Uptime Online Schema Changes for Maximizing Uptime
Online Schema Changes for Maximizing Uptime
 
Apache Flink vs Apache Spark - Reproducible experiments on cloud.
Apache Flink vs Apache Spark - Reproducible experiments on cloud.Apache Flink vs Apache Spark - Reproducible experiments on cloud.
Apache Flink vs Apache Spark - Reproducible experiments on cloud.
 
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
Kafka Summit SF 2017 - Streaming Processing in Python – 10 ways to avoid summ...
 
Apache Big Data EU 2015 - Phoenix
Apache Big Data EU 2015 - PhoenixApache Big Data EU 2015 - Phoenix
Apache Big Data EU 2015 - Phoenix
 
MySQL5.7 Innodb_enhance_parti_20160317
MySQL5.7 Innodb_enhance_parti_20160317MySQL5.7 Innodb_enhance_parti_20160317
MySQL5.7 Innodb_enhance_parti_20160317
 
Training Slides: Basics 103: The Power of Tungsten Connector / Proxy
Training Slides: Basics 103: The Power of Tungsten Connector / ProxyTraining Slides: Basics 103: The Power of Tungsten Connector / Proxy
Training Slides: Basics 103: The Power of Tungsten Connector / Proxy
 
Presto changes
Presto changesPresto changes
Presto changes
 
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache ApexApache Big Data EU 2016: Building Streaming Applications with Apache Apex
Apache Big Data EU 2016: Building Streaming Applications with Apache Apex
 
0.5mln packets per second with Erlang
0.5mln packets per second with Erlang0.5mln packets per second with Erlang
0.5mln packets per second with Erlang
 
From Zero to Hero with Kafka Connect
From Zero to Hero with Kafka ConnectFrom Zero to Hero with Kafka Connect
From Zero to Hero with Kafka Connect
 
Presto - Analytical Database. Overview and use cases.
Presto - Analytical Database. Overview and use cases.Presto - Analytical Database. Overview and use cases.
Presto - Analytical Database. Overview and use cases.
 
January 2015 HUG: Apache Flink: Fast and reliable large-scale data processing
January 2015 HUG: Apache Flink:  Fast and reliable large-scale data processingJanuary 2015 HUG: Apache Flink:  Fast and reliable large-scale data processing
January 2015 HUG: Apache Flink: Fast and reliable large-scale data processing
 
Postgres vision 2018: The Promise of zheap
Postgres vision 2018: The Promise of zheapPostgres vision 2018: The Promise of zheap
Postgres vision 2018: The Promise of zheap
 
Building a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and SparkBuilding a High-Performance Database with Scala, Akka, and Spark
Building a High-Performance Database with Scala, Akka, and Spark
 
Postgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to KnowPostgres Vision 2018: WAL: Everything You Want to Know
Postgres Vision 2018: WAL: Everything You Want to Know
 

En vedette

Operation research complete
Operation research completeOperation research complete
Operation research completeRohit Mishra
 
Happy halloween!
Happy halloween!Happy halloween!
Happy halloween!amjordan22
 
Mobile Computing IEEE 2014 Projects
Mobile Computing IEEE 2014 ProjectsMobile Computing IEEE 2014 Projects
Mobile Computing IEEE 2014 ProjectsVijay Karan
 
Imperious group presentation
Imperious group presentationImperious group presentation
Imperious group presentationDmitriy Shvets
 
2014 Investor Day
2014 Investor Day2014 Investor Day
2014 Investor DayCNOServices
 
Cadmun economics proyect
Cadmun economics proyectCadmun economics proyect
Cadmun economics proyectMarce Bravo
 
Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...
Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...
Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...Al Baha University
 
Cory mosley what matters most
Cory mosley what matters most Cory mosley what matters most
Cory mosley what matters most Sean Bradley
 
An Overview of VIEW
An Overview of VIEWAn Overview of VIEW
An Overview of VIEWShiyong Lu
 
026 30 03-2014 am الكلمة الخامسة - أنا عطشان
026  30  03-2014 am            الكلمة الخامسة  - أنا عطشان026  30  03-2014 am            الكلمة الخامسة  - أنا عطشان
026 30 03-2014 am الكلمة الخامسة - أنا عطشانIbrahimia Church Ftriends
 
Microsoft Power Point Brett Campbellv2 [Compatibility Mode]
Microsoft Power Point   Brett Campbellv2 [Compatibility Mode]Microsoft Power Point   Brett Campbellv2 [Compatibility Mode]
Microsoft Power Point Brett Campbellv2 [Compatibility Mode]brettpcampbell
 

En vedette (20)

Operation research complete
Operation research completeOperation research complete
Operation research complete
 
Happy halloween!
Happy halloween!Happy halloween!
Happy halloween!
 
Mobile Computing IEEE 2014 Projects
Mobile Computing IEEE 2014 ProjectsMobile Computing IEEE 2014 Projects
Mobile Computing IEEE 2014 Projects
 
Imperious group presentation
Imperious group presentationImperious group presentation
Imperious group presentation
 
Cato
CatoCato
Cato
 
Financial management
Financial managementFinancial management
Financial management
 
devopsdays Rome
devopsdays Romedevopsdays Rome
devopsdays Rome
 
2014 Investor Day
2014 Investor Day2014 Investor Day
2014 Investor Day
 
Cadmun economics proyect
Cadmun economics proyectCadmun economics proyect
Cadmun economics proyect
 
B&NFinal
B&NFinalB&NFinal
B&NFinal
 
Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...
Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...
Inhibition, kinetic and thermodynamic effects of new Azo derivatives on iron ...
 
Yhteisen talouden talkoot
Yhteisen talouden talkootYhteisen talouden talkoot
Yhteisen talouden talkoot
 
صفات قلب الراعي
صفات قلب الراعيصفات قلب الراعي
صفات قلب الراعي
 
Cory mosley what matters most
Cory mosley what matters most Cory mosley what matters most
Cory mosley what matters most
 
451782
451782451782
451782
 
Hebrew Kings
Hebrew KingsHebrew Kings
Hebrew Kings
 
An Overview of VIEW
An Overview of VIEWAn Overview of VIEW
An Overview of VIEW
 
026 30 03-2014 am الكلمة الخامسة - أنا عطشان
026  30  03-2014 am            الكلمة الخامسة  - أنا عطشان026  30  03-2014 am            الكلمة الخامسة  - أنا عطشان
026 30 03-2014 am الكلمة الخامسة - أنا عطشان
 
Farewell Sermon
Farewell SermonFarewell Sermon
Farewell Sermon
 
Microsoft Power Point Brett Campbellv2 [Compatibility Mode]
Microsoft Power Point   Brett Campbellv2 [Compatibility Mode]Microsoft Power Point   Brett Campbellv2 [Compatibility Mode]
Microsoft Power Point Brett Campbellv2 [Compatibility Mode]
 

Similaire à Howmysqlworks

20140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp02
20140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp0220140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp02
20140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp02Francisco Gonçalves
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLMorgan Tocker
 
Rubyslava + PyVo #48
Rubyslava + PyVo #48Rubyslava + PyVo #48
Rubyslava + PyVo #48Jozef Képesi
 
Introduction to TokuDB v7.5 and Read Free Replication
Introduction to TokuDB v7.5 and Read Free ReplicationIntroduction to TokuDB v7.5 and Read Free Replication
Introduction to TokuDB v7.5 and Read Free ReplicationTim Callaghan
 
Get More Out of MySQL with TokuDB
Get More Out of MySQL with TokuDBGet More Out of MySQL with TokuDB
Get More Out of MySQL with TokuDBTim Callaghan
 
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
 
Loadays MySQL
Loadays MySQLLoadays MySQL
Loadays MySQLlefredbe
 
MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...
MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...
MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...MongoDB
 
Gruter TECHDAY 2014 Realtime Processing in Telco
Gruter TECHDAY 2014 Realtime Processing in TelcoGruter TECHDAY 2014 Realtime Processing in Telco
Gruter TECHDAY 2014 Realtime Processing in TelcoGruter
 
JSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance TuningJSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance TuningKenichiro Nakamura
 
confessions of a dba: worst and best things I've done in production - Open So...
confessions of a dba: worst and best things I've done in production - Open So...confessions of a dba: worst and best things I've done in production - Open So...
confessions of a dba: worst and best things I've done in production - Open So...emilyslocombe
 
All About Storeconfigs
All About StoreconfigsAll About Storeconfigs
All About StoreconfigsBrice Figureau
 
Nexcess Magento Imagine 2014 Performance Breakout
Nexcess Magento Imagine 2014 Performance BreakoutNexcess Magento Imagine 2014 Performance Breakout
Nexcess Magento Imagine 2014 Performance BreakoutNexcess.net LLC
 
Pluk2013 bodybuilding ratheesh
Pluk2013 bodybuilding ratheeshPluk2013 bodybuilding ratheesh
Pluk2013 bodybuilding ratheeshRatheesh Kaniyala
 
Sql server scalability fundamentals
Sql server scalability fundamentalsSql server scalability fundamentals
Sql server scalability fundamentalsChris Adkin
 
Benchmarking, Load Testing, and Preventing Terrible Disasters
Benchmarking, Load Testing, and Preventing Terrible DisastersBenchmarking, Load Testing, and Preventing Terrible Disasters
Benchmarking, Load Testing, and Preventing Terrible DisastersMongoDB
 
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Lucidworks
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
Building a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrBuilding a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrRahul Jain
 
VLDB Administration Strategies
VLDB Administration StrategiesVLDB Administration Strategies
VLDB Administration StrategiesMurilo Miranda
 

Similaire à Howmysqlworks (20)

20140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp02
20140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp0220140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp02
20140128 webinar-get-more-out-of-mysql-with-tokudb-140319063324-phpapp02
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
 
Rubyslava + PyVo #48
Rubyslava + PyVo #48Rubyslava + PyVo #48
Rubyslava + PyVo #48
 
Introduction to TokuDB v7.5 and Read Free Replication
Introduction to TokuDB v7.5 and Read Free ReplicationIntroduction to TokuDB v7.5 and Read Free Replication
Introduction to TokuDB v7.5 and Read Free Replication
 
Get More Out of MySQL with TokuDB
Get More Out of MySQL with TokuDBGet More Out of MySQL with TokuDB
Get More Out of MySQL with TokuDB
 
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
 
Loadays MySQL
Loadays MySQLLoadays MySQL
Loadays MySQL
 
MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...
MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...
MongoDB .local Toronto 2019: Finding the Right Atlas Cluster Size: Does this ...
 
Gruter TECHDAY 2014 Realtime Processing in Telco
Gruter TECHDAY 2014 Realtime Processing in TelcoGruter TECHDAY 2014 Realtime Processing in Telco
Gruter TECHDAY 2014 Realtime Processing in Telco
 
JSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance TuningJSSUG: SQL Sever Performance Tuning
JSSUG: SQL Sever Performance Tuning
 
confessions of a dba: worst and best things I've done in production - Open So...
confessions of a dba: worst and best things I've done in production - Open So...confessions of a dba: worst and best things I've done in production - Open So...
confessions of a dba: worst and best things I've done in production - Open So...
 
All About Storeconfigs
All About StoreconfigsAll About Storeconfigs
All About Storeconfigs
 
Nexcess Magento Imagine 2014 Performance Breakout
Nexcess Magento Imagine 2014 Performance BreakoutNexcess Magento Imagine 2014 Performance Breakout
Nexcess Magento Imagine 2014 Performance Breakout
 
Pluk2013 bodybuilding ratheesh
Pluk2013 bodybuilding ratheeshPluk2013 bodybuilding ratheesh
Pluk2013 bodybuilding ratheesh
 
Sql server scalability fundamentals
Sql server scalability fundamentalsSql server scalability fundamentals
Sql server scalability fundamentals
 
Benchmarking, Load Testing, and Preventing Terrible Disasters
Benchmarking, Load Testing, and Preventing Terrible DisastersBenchmarking, Load Testing, and Preventing Terrible Disasters
Benchmarking, Load Testing, and Preventing Terrible Disasters
 
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
Building a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache SolrBuilding a Large Scale SEO/SEM Application with Apache Solr
Building a Large Scale SEO/SEM Application with Apache Solr
 
VLDB Administration Strategies
VLDB Administration StrategiesVLDB Administration Strategies
VLDB Administration Strategies
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Dernier (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Howmysqlworks

  • 2. 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 ! !
  • 3. Today • High level overview of MySQL • Look inside MySQL server • Talk through how InnoDB performs queries • Schema changes and online schema changes ! !
  • 4. 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) !
  • 5. How it works mysqld mysql client tcp:3306 filesocket ServerClient libmysql mysql lib ORM host$ mysql host$ mysqld_safe! host$ mysqld
  • 6. 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 !
  • 7. Inside mysqld mysqld storage engine(s) MyISAM / InnoDB / Memory / etc tcp:3306 filesocket Getting the query and responding bits and bytes stuff API
  • 8. Inside mysqld mysqld storage engine(s) MyISAM / InnoDB / Memory / etc tcp:3306 filesocket API
  • 9. Inside mysqld mysqld storage engine(s) MyISAM / InnoDB / Memory / etc tcp:3306 filesocket Parse query and convert to SE API calls. API
  • 10. Inside mysqld mysqld Storage engines(s) tcp:3306 filesocket API query cache binary log join / sort buffers Binary Log for replication Buffers: Kinda how much batching to storage API to save cost
  • 11. The bad parts - binary log mysqld tcp:3306 filesocket query cache binary log join / 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
  • 12. The bad parts - binary log mysqld Innodb Table 1 tcp:3306 filesocket query cache binary log join / sort buffers Highly concurrent InnoDB needs its queries, serialized down to replicate to slave MyISAM Table 2
  • 13. Compare to other DBs DB server tcp:x filesocket? performance knobs transaction log
  • 14. The bad parts - query cache mysqld Innodb Table 1 tcp:3306 filesocket query cache binary log join / sort buffers Can only work on an entire table level & uses LRU MyISAM Table 2
  • 15. The bad parts - query cache mysqld Innodb Table 1 tcp:3306 filesocket query cache binary log join / sort buffers All ‘update/insert/delete’ blocks all transactions to ensure correct state. It actually slows ! things down MyISAM Table 2
  • 16. 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
  • 17. 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% ! !
  • 20. 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
  • 21. Key parts of InnoDB Innodb API
  • 22. Key parts of InnoDB Table space (whats on disk) redo log Innodb bufferpool memory! ib_log1! ib_log2! sometable.ibd! ib_data!
  • 23. 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
  • 24. Key parts of InnoDB Table space redo log bufferpool • Black is the base metadata
  • 25. What is bufferpool Table space redo log bufferpool • In memory version of hot tablespace pages
  • 26. What is redo log Table space redo log bufferpool • An append only log file of changes
  • 27. What is table space Table space redo log bufferpool • The raw files - but it may not be always up-to-date
  • 28. Lets run some queries Table space redo log bufferpool • First - lets fill up our database with data
  • 29. Lets run some queries Table space redo log bufferpool • mysql> select * from red;
  • 30. Lets run some queries Table space redo log bufferpool • mysql> select * from red; mysqld parses the query and sends ! API calls to InnoDB
  • 31. Lets run some queries Table space redo log bufferpool • mysql> select * from red; Is red in bufferpool?
  • 32. 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!
  • 33. Lets run some queries Table space redo log bufferpool • mysql> select * from red; Respond to API calls to mysqld
  • 34. Lets run some queries Table space redo log bufferpool • mysql> select * from red; Parse results ! second pass sort if necessary ! return to client
  • 35. Lets run some queries Table space redo log bufferpool • mysql> select * from red; #again
  • 36. Lets run some queries Table space redo log bufferpool • mysql> select * from red; mysqld parses the query and sends ! API calls to InnoDB
  • 37. Lets run some queries Table space redo log bufferpool • mysql> select * from red; Is red in bufferpool? - yes
  • 38. Lets run some queries Table space redo log bufferpool • mysql> select * from red; Respond to API calls to mysqld
  • 39. Lets run some queries Table space redo log bufferpool • mysql> select * from red; Parse results ! second pass sort if necessary ! return to client
  • 40. Lets run some queries Table space redo log bufferpool • mysql> select * from brown; What if bufferpool is full?
  • 41. 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
  • 42. Lets run some queries Table space redo log bufferpool • mysql> select * from blue; ! Load in blue as before and return
  • 43. Lets run some queries Table space redo log bufferpool • mysql> update blue set A=B where ID=1; ! Is page in bufferpool? yes
  • 44. 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
  • 45. 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!
  • 46. 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!
  • 47. 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!
  • 48. 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 ! !
  • 49. Lets run some queries Table space redo log bufferpool • mysql> insert into yellow values (1,2,3,4); ! Is space in bufferpool?!
  • 50. 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)
  • 51. Lets run some queries Table space redo log bufferpool • mysql> insert into yellow values (1,2,3,4); ! Send OK back to client!
  • 52. 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!
  • 53. Schema changes • Everyone hates them • They are not transactional • They are blocking (well most) • How do they work? !
  • 55. Lets add a few more Storage engines(s) tcp:3306 filesocket API table meta data binary log Table triggers functions / procedures
  • 57. mytbl mysql> CREATE TABLE mytbl 
 (a INT, b CHAR (20), INDEX (a)) ENGINE=InnoDB; Schema changes
  • 58. mytbl Schema changes mysql> ALTER TABLE mytbl 
 ADD COLUMN age INT;
  • 59. mytbl Schema changes mysql> ALTER TABLE mytbl 
 ADD COLUMN age INT; ! Wait for any open transactions to close and then ! lock access to the table! block
  • 60. mytbl Schema changes mysql> ALTER TABLE mytbl 
 ADD COLUMN age INT; ! Create a new ‘hidden’ table with the new schema! block .mytbl
  • 61. mytbl Schema changes mysql> ALTER TABLE mytbl 
 ADD COLUMN age INT; ! Do an internal ‘mysqldump’ / ‘mysqlrestore’! block .mytbl
  • 62. mytbl Schema changes mysql> ALTER TABLE mytbl 
 ADD COLUMN age INT; ! Do a switch-a-roo! block .mytbl
  • 63. Schema changes mysql> ALTER TABLE mytbl 
 ADD COLUMN age INT; ! Unblock and send OK back to client! mytbl
  • 64. 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 !
  • 66. mysqld mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… pt-online-schema-change soundclouds lhm etc
  • 67. mysqld mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl ! Creates another table with the updated schema in the client!
  • 68. mysqld mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl ! Creates a set of triggers on the main table! triggers
  • 69. mysqld mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl ! selects the entire table (in batches) and inserts into the new table! ! ! This can take a long time! triggers
  • 70. mysqld mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl triggers client mysql> select ! Whilst the new table is being built, selects still go to the old table!
  • 71. mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl triggers client 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!
  • 72. mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl triggers client mysql> INSERT ! Inserts also happen the same way
  • 73. mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl triggers ! Eventually the table population finishes and a ‘RENAME table’ action is performed (which is quick)
  • 74. mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… .mytbl meta .mytbl triggers ! Eventually the table population finishes. This is the only ‘blocking’ time block block
  • 75. mytbl Online schema changes 5.1/5.5 mytbl meta client mysql> ALTER… ! The schema change tool finishes
  • 76. Online schema changes in 5.6 • All that ‘switch-a-roo’ logic is now within mysqld itself !
  • 77. 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 ! !