SlideShare a Scribd company logo
Other MySQL-verses
Our journey to Aurora
Our journey to Aurora
Our journey to Aurora
Our journey to Aurora
Our journey to Aurora
Our journey to Aurora
Our journey to Aurora
Our journey to Aurora
Indexes
Indexes
Primary key index
Secondary key index
Clustered key index
Hash index*
Primary key index (btree)
Primary key index (btree)
Rows are attached to the
Leaf node as part of same
data-structure
Secondary key index (btree)
Secondary key index (btree)
Leaf node have pointers to
PK of rows
Clustered Key
In absence of PK/uniq key,
MySQL creates a hidden
clustered key.
Index use
● Left prefix rule
○ Name, ID, country
■ Select … where ID = 3 and country = us
■ Select … where ID = 3
■ Select … where country = us
■ Select … where Name = ‘blah’ and country = us
■ Select … where Name = ‘blah’ and ID = 4
Index use
● Left prefix rule
○ Name, ID, country
■ Select … where ID = 3 and country = us
■ Select … where ID = 3
■ Select … where country = us
■ Select … where Name = ‘blah’ and country = us
■ Select … where Name = ‘blah’ and ID = 4
● Duplicate indexes
○ Name, country
○ Name, country, zip
○ Name, zip
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
○ => in the btree, 70% of rows will be under male node.
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
○ => in the btree, 70% of rows will be under male node.
○ => since 2ndary index, the node has pointers to 70% of rows
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
○ => in the btree, 70% of rows will be under male node.
○ => since 2ndary index, the node has pointers to 70% of rows
○ What does MySQL Do ?
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
○ => in the btree, 70% of rows will be under male node.
○ => since 2ndary index, the node has pointers to 70% of rows
○ What does MySQL Do ?
■ Does it read index , traverse it and then go to disk for the 70% of data ?
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
○ => in the btree, 70% of rows will be under male node.
○ => since 2ndary index, the node has pointers to 70% of rows
○ What does MySQL Do ?
■ Does it read index , traverse it and then go to disk for the 70% of data ?
■ It does not , it bypasses index and goes to disk directly
Index use
● Selectivity rule
○ Select … where gender = male
○ Say 2ndary index on gender (cardinality is say 2 = male/female)
○ Say 70 % of rows are male
○ => in the btree, 70% of rows will be under male node.
○ => since 2ndary index, the node has pointers to 70% of rows
○ What does MySQL Do ?
■ Does it read index , traverse it and then go to disk for the 70% of data ?
■ It does not , it bypasses index and goes to disk directly
■ It does a table scan ! (more effective).
● Explain might indicate use of index but in practice it does not!
Storage engines
Innodb *
MyIsam
Memory (can create hash index)
Federated
NDB
Storage engines
Innodb * (enable adaptive hash idx)
MyIsam
Memory (can create hash index)
Federated
NDB
Lock wait timeout exceeded error
Deadlocks
Lock errors
1. Lock wait timeout exceeded:
a. set global innodb_lock_wait_timeout = x; <default is 150 sec i believe>
b. Show engine innodb status; (when txn is blocked, u can see on whats its blocked)
c. Show process list; (list of connections and what they are doing)
Lock errors
1. Lock wait timeout exceeded:
a. set global innodb_lock_wait_timeout = x; <default is 150 sec i believe>
b. Show engine innodb status; (when txn is blocked, u can see on whats its blocked)
c. Show process list; (list of connections and what they are doing)
2. Deadlocks
a. You have to do nothing. Auto resolved by Mysql - randomly 1 txn wins and other rolled back.
b. Show engine innodb status - shows u latest deadlocks that occurred
Select for update
Select for share
Read locks
1. Select for update
a. Use carefully.
i. You might end up locking part of the index tree. (select .. where cost > 50)
b. Good practice is to select row ids first and then update (i.e. specific row locks)
i. Select id where cost > 50
ii. Update where id = x
Read locks
1. Select for update
a. Use carefully.
i. You might end up locking part of the index tree. (select .. where cost > 50)
b. Good practice is to select row ids first and then update (i.e. specific row locks)
i. Select id where cost > 50
ii. Update where id = x
2. Select for share
a. It’s a pure read lock. Writers will wait for read to complete
Repeatable read
Read committed
Read un-committed
Serializable
Isolation levels
1. Repeatable read (default i believe in aurora)
a. The same read if done again in the txn sees the same thing (except if some other txn commits
before the second read)
Isolation levels
1. Repeatable read (default i believe in aurora)
a. The same read if done again in the txn sees the same thing (except if some other txn commits
before the second read)
2. Read Committed (newly added)
a. Every read in the txn sees the latest state
Isolation levels
1. Repeatable read (default i believe in aurora)
a. The same read if done again in the txn sees the same thing (except if some other txn commits
before the second read)
2. Read Committed (newly added)
a. Every read in the txn sees the latest state
3. Read un-Committed (not recommended)
a. A read in the txn sees the dirty state of uncommitted txns
Isolation levels
1. Repeatable read (default i believe in aurora)
a. The same read if done again in the txn sees the same thing (except if some other txn commits
before the second read)
2. Read Committed (newly added)
a. Every read in the txn sees the latest state
3. Read un-Committed (not recommended)
a. A read in the txn sees the dirty state of uncommitted txns
4. Serializable
a. All txns go in sequence
Why is this important ?
For every transaction:
Why is this important ?
For every transaction:
1. Rows updated:
a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
Why is this important ?
For every transaction:
1. Rows updated:
a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
b. Even newly inserted rows are stored in undo log.
Why is this important ?
For every transaction:
1. Rows updated:
a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
b. Even newly inserted rows are stored in undo log.
c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
Why is this important ?
For every transaction:
1. Rows updated:
a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
b. Even newly inserted rows are stored in undo log.
c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
2. Rows being read:
a. A snapshot is stored in the undo log.
Why is this important ?
For every transaction:
1. Rows updated:
a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
b. Even newly inserted rows are stored in undo log.
c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
2. Rows being read:
a. A snapshot is stored in the undo log.
b. It helps satisfy the isolation level of txn
Why is this important ?
For every transaction:
1. Rows updated:
a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
b. Even newly inserted rows are stored in undo log.
c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
2. Rows being read:
a. A snapshot is stored in the undo log.
b. It helps satisfy the isolation level of txn
c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
● Storage is shared across nodes
○ => a single undo log that is shared between writer & reader
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
● Storage is shared across nodes
○ => a single undo log that is shared between writer & reader
● Imagine long running transactions
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
● Storage is shared across nodes
○ => a single undo log that is shared between writer & reader
● Imagine long running transactions
○ Based on isolation level
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
● Storage is shared across nodes
○ => a single undo log that is shared between writer & reader
● Imagine long running transactions
○ Based on isolation level
○ The undo log might keep growing …
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
● Storage is shared across nodes
○ => a single undo log that is shared between writer & reader
● Imagine long running transactions
○ Based on isolation level
○ The undo log might keep growing …
○ Purging / garbage collection will not occur…
Aurora Undo Log
● Normally in vanilla mysql,
○ each node has its own storage.
● Storage is shared across nodes
○ => a single undo log that is shared between writer & reader
● Imagine long running transactions
○ Based on isolation level
○ The undo log might keep growing …
○ Purging / garbage collection will not occur…
○ At some point, Paralysis due to overdue GC
Writes to Aurora & Cost
● Keep an eye on IOPS
○ IOPS ++ == $ ++
● Batch your writes if possible
● Compress your data before sending.
1. Mysql error log
2. Mysql slow query log
3. Metrics
Monitoring
1. Never ignore mysql error logs. It might have something critical mentioned. Its
your best friend !
2. Can Enable slow query logs to keep track of slow running queries
3. Metrics
a. Recommend Percona PMM (available metrics are graphed nicely)
b. Buffer pool usage metrics
c. Undo log history growth / RollbackSegmentHistoryListLength metric
d. Insert latencies
e. IOPS usage
Aurora Parallel query
1. The only feature missing in other mysql variants.
2. Allows for parallelism in a select query
Aurora Parallel query
1. The only feature missing in other mysql variants.
2. Allows for parallelism in a select query
3. Bypasses the in-memory buffer pool doing table scans on disk. :)
Aurora Parallel query
1. The only feature missing in other mysql variants.
2. Allows for parallelism in a select query
3. Bypasses the in-memory buffer pool doing table scans on disk. :)
a. => IOPS => $ :)
Aurora Parallel query
1. The only feature missing in other mysql variants.
2. Allows for parallelism in a select query
3. Bypasses the in-memory buffer pool doing table scans on disk. :)
a. => IOPS => $ :)
4. Supposedly good for your reporting queries
Other helpful stuff
1. Use START TRANSACTION READ ONLY
; (less bookkeeping for readonly)
2. Run an explain on your query; be aware if index is used.
a. Explains are not always accurate
3. Show process list; (i used to kill long running transactions/ sleeping transactions - no
mercy :) )
4. Show engine innodb status;
5. You have an index on group by columns but order by columns not in index ?
6. Joining 2 tables - think of 2 for loops (keep outer for loop short)
7. Query Cache - apparently works well in aurora ! (discouraged in rds/mysql)
Finally ● Make 1 change at a time
○ Change
○ See effect
○ Make next change
Finally
● Make 1 change at a time
○ Change
○ See effect
○ Make next change
● Keep an eye on $ cost
Select QNS from you;
select Thank you from me;
Who am I ?
Ex Mysql Guy at Flipkart / Data guy at Trustana
linkedin.com/in/213vishnu/
mash213.wordpress.com/conferences/
https://twitter.com/sweetweet213

More Related Content

Similar to A talk on mysql & aurora

Back to Basics 3: Scaling 30,000 Requests a Second with MongoDB
Back to Basics 3: Scaling 30,000 Requests a Second with MongoDBBack to Basics 3: Scaling 30,000 Requests a Second with MongoDB
Back to Basics 3: Scaling 30,000 Requests a Second with MongoDB
MongoDB
 
Scaling to 30,000 Requests Per Second and Beyond with MongoDB
Scaling to 30,000 Requests Per Second and Beyond with MongoDBScaling to 30,000 Requests Per Second and Beyond with MongoDB
Scaling to 30,000 Requests Per Second and Beyond with MongoDB
mchesnut
 
LinuxCon Japan 2010 suzaki
LinuxCon Japan 2010 suzakiLinuxCon Japan 2010 suzaki
LinuxCon Japan 2010 suzaki
Kuniyasu Suzaki
 
Managing Data and Operation Distribution In MongoDB
Managing Data and Operation Distribution In MongoDBManaging Data and Operation Distribution In MongoDB
Managing Data and Operation Distribution In MongoDB
Jason Terpko
 
Low Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLow Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).ppt
LearnWithJCM
 
Managing data and operation distribution in MongoDB
Managing data and operation distribution in MongoDBManaging data and operation distribution in MongoDB
Managing data and operation distribution in MongoDB
Antonios Giannopoulos
 
Python made easy
Python made easy Python made easy
Python made easy
Abhishek kumar
 
Distributed Coordination
Distributed CoordinationDistributed Coordination
Distributed Coordination
Luis Galárraga
 
Sangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL JediSangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL Jedi
Connor McDonald
 
what every web and app developer should know about multithreading
what every web and app developer should know about multithreadingwhat every web and app developer should know about multithreading
what every web and app developer should know about multithreading
Ilya Haykinson
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQL
Connor McDonald
 
Cache aware hybrid sorter
Cache aware hybrid sorterCache aware hybrid sorter
Cache aware hybrid sorter
Manchor Ko
 
Cassandra introduction apache con 2014 budapest
Cassandra introduction apache con 2014 budapestCassandra introduction apache con 2014 budapest
Cassandra introduction apache con 2014 budapest
Duyhai Doan
 
C language
C languageC language
C language
Robo India
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
Boris Hristov
 
Jvm memory model
Jvm memory modelJvm memory model
Jvm memory model
Yoav Avrahami
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
Tony Albrecht
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
Eman magdy
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
aaronmorton
 
Python Quick Start
Python Quick StartPython Quick Start
Python Quick Start
Abbas Ali
 

Similar to A talk on mysql & aurora (20)

Back to Basics 3: Scaling 30,000 Requests a Second with MongoDB
Back to Basics 3: Scaling 30,000 Requests a Second with MongoDBBack to Basics 3: Scaling 30,000 Requests a Second with MongoDB
Back to Basics 3: Scaling 30,000 Requests a Second with MongoDB
 
Scaling to 30,000 Requests Per Second and Beyond with MongoDB
Scaling to 30,000 Requests Per Second and Beyond with MongoDBScaling to 30,000 Requests Per Second and Beyond with MongoDB
Scaling to 30,000 Requests Per Second and Beyond with MongoDB
 
LinuxCon Japan 2010 suzaki
LinuxCon Japan 2010 suzakiLinuxCon Japan 2010 suzaki
LinuxCon Japan 2010 suzaki
 
Managing Data and Operation Distribution In MongoDB
Managing Data and Operation Distribution In MongoDBManaging Data and Operation Distribution In MongoDB
Managing Data and Operation Distribution In MongoDB
 
Low Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).pptLow Level Prog. (from 201-c).ppt
Low Level Prog. (from 201-c).ppt
 
Managing data and operation distribution in MongoDB
Managing data and operation distribution in MongoDBManaging data and operation distribution in MongoDB
Managing data and operation distribution in MongoDB
 
Python made easy
Python made easy Python made easy
Python made easy
 
Distributed Coordination
Distributed CoordinationDistributed Coordination
Distributed Coordination
 
Sangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL JediSangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL Jedi
 
what every web and app developer should know about multithreading
what every web and app developer should know about multithreadingwhat every web and app developer should know about multithreading
what every web and app developer should know about multithreading
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQL
 
Cache aware hybrid sorter
Cache aware hybrid sorterCache aware hybrid sorter
Cache aware hybrid sorter
 
Cassandra introduction apache con 2014 budapest
Cassandra introduction apache con 2014 budapestCassandra introduction apache con 2014 budapest
Cassandra introduction apache con 2014 budapest
 
C language
C languageC language
C language
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
 
Jvm memory model
Jvm memory modelJvm memory model
Jvm memory model
 
Parallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical SectionParallel Programming: Beyond the Critical Section
Parallel Programming: Beyond the Critical Section
 
Basics in algorithms and data structure
Basics in algorithms and data structure Basics in algorithms and data structure
Basics in algorithms and data structure
 
Introduction to Cassandra
Introduction to CassandraIntroduction to Cassandra
Introduction to Cassandra
 
Python Quick Start
Python Quick StartPython Quick Start
Python Quick Start
 

More from vishnu rao

Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
vishnu rao
 
Mysql Relay log - the unsung hero
Mysql Relay log - the unsung heroMysql Relay log - the unsung hero
Mysql Relay log - the unsung hero
vishnu rao
 
simple introduction to hadoop
simple introduction to hadoopsimple introduction to hadoop
simple introduction to hadoop
vishnu rao
 
Druid beginner performance tips
Druid beginner performance tipsDruid beginner performance tips
Druid beginner performance tips
vishnu rao
 
Demystifying datastores
Demystifying datastoresDemystifying datastores
Demystifying datastores
vishnu rao
 
Visualising Basic Concepts of Docker
Visualising Basic Concepts of Docker Visualising Basic Concepts of Docker
Visualising Basic Concepts of Docker
vishnu rao
 
StormWars - when the data stream shrinks
StormWars - when the data stream shrinksStormWars - when the data stream shrinks
StormWars - when the data stream shrinks
vishnu rao
 
Punch clock for debugging apache storm
Punch clock for  debugging apache stormPunch clock for  debugging apache storm
Punch clock for debugging apache storm
vishnu rao
 
a wild Supposition: can MySQL be Kafka ?
a wild Supposition: can MySQL be Kafka ?a wild Supposition: can MySQL be Kafka ?
a wild Supposition: can MySQL be Kafka ?
vishnu rao
 
Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...
Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...
Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...
vishnu rao
 

More from vishnu rao (10)

Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Mysql Relay log - the unsung hero
Mysql Relay log - the unsung heroMysql Relay log - the unsung hero
Mysql Relay log - the unsung hero
 
simple introduction to hadoop
simple introduction to hadoopsimple introduction to hadoop
simple introduction to hadoop
 
Druid beginner performance tips
Druid beginner performance tipsDruid beginner performance tips
Druid beginner performance tips
 
Demystifying datastores
Demystifying datastoresDemystifying datastores
Demystifying datastores
 
Visualising Basic Concepts of Docker
Visualising Basic Concepts of Docker Visualising Basic Concepts of Docker
Visualising Basic Concepts of Docker
 
StormWars - when the data stream shrinks
StormWars - when the data stream shrinksStormWars - when the data stream shrinks
StormWars - when the data stream shrinks
 
Punch clock for debugging apache storm
Punch clock for  debugging apache stormPunch clock for  debugging apache storm
Punch clock for debugging apache storm
 
a wild Supposition: can MySQL be Kafka ?
a wild Supposition: can MySQL be Kafka ?a wild Supposition: can MySQL be Kafka ?
a wild Supposition: can MySQL be Kafka ?
 
Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...
Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...
Build your own Real Time Analytics and Visualization, Enable Complex Event Pr...
 

Recently uploaded

Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
DianaGray10
 

Recently uploaded (20)

Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
What is an RPA CoE? Session 2 – CoE Roles
What is an RPA CoE?  Session 2 – CoE RolesWhat is an RPA CoE?  Session 2 – CoE Roles
What is an RPA CoE? Session 2 – CoE Roles
 

A talk on mysql & aurora

  • 1.
  • 3. Our journey to Aurora
  • 4. Our journey to Aurora
  • 5. Our journey to Aurora
  • 6. Our journey to Aurora
  • 7. Our journey to Aurora
  • 8. Our journey to Aurora
  • 9. Our journey to Aurora
  • 10. Our journey to Aurora
  • 12. Indexes Primary key index Secondary key index Clustered key index Hash index*
  • 13. Primary key index (btree)
  • 14. Primary key index (btree) Rows are attached to the Leaf node as part of same data-structure
  • 16. Secondary key index (btree) Leaf node have pointers to PK of rows
  • 17. Clustered Key In absence of PK/uniq key, MySQL creates a hidden clustered key.
  • 18. Index use ● Left prefix rule ○ Name, ID, country ■ Select … where ID = 3 and country = us ■ Select … where ID = 3 ■ Select … where country = us ■ Select … where Name = ‘blah’ and country = us ■ Select … where Name = ‘blah’ and ID = 4
  • 19. Index use ● Left prefix rule ○ Name, ID, country ■ Select … where ID = 3 and country = us ■ Select … where ID = 3 ■ Select … where country = us ■ Select … where Name = ‘blah’ and country = us ■ Select … where Name = ‘blah’ and ID = 4 ● Duplicate indexes ○ Name, country ○ Name, country, zip ○ Name, zip
  • 20. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male
  • 21. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male ○ => in the btree, 70% of rows will be under male node.
  • 22. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male ○ => in the btree, 70% of rows will be under male node. ○ => since 2ndary index, the node has pointers to 70% of rows
  • 23. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male ○ => in the btree, 70% of rows will be under male node. ○ => since 2ndary index, the node has pointers to 70% of rows ○ What does MySQL Do ?
  • 24. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male ○ => in the btree, 70% of rows will be under male node. ○ => since 2ndary index, the node has pointers to 70% of rows ○ What does MySQL Do ? ■ Does it read index , traverse it and then go to disk for the 70% of data ?
  • 25. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male ○ => in the btree, 70% of rows will be under male node. ○ => since 2ndary index, the node has pointers to 70% of rows ○ What does MySQL Do ? ■ Does it read index , traverse it and then go to disk for the 70% of data ? ■ It does not , it bypasses index and goes to disk directly
  • 26. Index use ● Selectivity rule ○ Select … where gender = male ○ Say 2ndary index on gender (cardinality is say 2 = male/female) ○ Say 70 % of rows are male ○ => in the btree, 70% of rows will be under male node. ○ => since 2ndary index, the node has pointers to 70% of rows ○ What does MySQL Do ? ■ Does it read index , traverse it and then go to disk for the 70% of data ? ■ It does not , it bypasses index and goes to disk directly ■ It does a table scan ! (more effective). ● Explain might indicate use of index but in practice it does not!
  • 27. Storage engines Innodb * MyIsam Memory (can create hash index) Federated NDB
  • 28. Storage engines Innodb * (enable adaptive hash idx) MyIsam Memory (can create hash index) Federated NDB
  • 29.
  • 30. Lock wait timeout exceeded error Deadlocks
  • 31. Lock errors 1. Lock wait timeout exceeded: a. set global innodb_lock_wait_timeout = x; <default is 150 sec i believe> b. Show engine innodb status; (when txn is blocked, u can see on whats its blocked) c. Show process list; (list of connections and what they are doing)
  • 32. Lock errors 1. Lock wait timeout exceeded: a. set global innodb_lock_wait_timeout = x; <default is 150 sec i believe> b. Show engine innodb status; (when txn is blocked, u can see on whats its blocked) c. Show process list; (list of connections and what they are doing) 2. Deadlocks a. You have to do nothing. Auto resolved by Mysql - randomly 1 txn wins and other rolled back. b. Show engine innodb status - shows u latest deadlocks that occurred
  • 34. Read locks 1. Select for update a. Use carefully. i. You might end up locking part of the index tree. (select .. where cost > 50) b. Good practice is to select row ids first and then update (i.e. specific row locks) i. Select id where cost > 50 ii. Update where id = x
  • 35. Read locks 1. Select for update a. Use carefully. i. You might end up locking part of the index tree. (select .. where cost > 50) b. Good practice is to select row ids first and then update (i.e. specific row locks) i. Select id where cost > 50 ii. Update where id = x 2. Select for share a. It’s a pure read lock. Writers will wait for read to complete
  • 36.
  • 37. Repeatable read Read committed Read un-committed Serializable
  • 38. Isolation levels 1. Repeatable read (default i believe in aurora) a. The same read if done again in the txn sees the same thing (except if some other txn commits before the second read)
  • 39. Isolation levels 1. Repeatable read (default i believe in aurora) a. The same read if done again in the txn sees the same thing (except if some other txn commits before the second read) 2. Read Committed (newly added) a. Every read in the txn sees the latest state
  • 40. Isolation levels 1. Repeatable read (default i believe in aurora) a. The same read if done again in the txn sees the same thing (except if some other txn commits before the second read) 2. Read Committed (newly added) a. Every read in the txn sees the latest state 3. Read un-Committed (not recommended) a. A read in the txn sees the dirty state of uncommitted txns
  • 41. Isolation levels 1. Repeatable read (default i believe in aurora) a. The same read if done again in the txn sees the same thing (except if some other txn commits before the second read) 2. Read Committed (newly added) a. Every read in the txn sees the latest state 3. Read un-Committed (not recommended) a. A read in the txn sees the dirty state of uncommitted txns 4. Serializable a. All txns go in sequence
  • 42. Why is this important ? For every transaction:
  • 43. Why is this important ? For every transaction: 1. Rows updated: a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored.
  • 44. Why is this important ? For every transaction: 1. Rows updated: a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored. b. Even newly inserted rows are stored in undo log.
  • 45. Why is this important ? For every transaction: 1. Rows updated: a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored. b. Even newly inserted rows are stored in undo log. c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
  • 46. Why is this important ? For every transaction: 1. Rows updated: a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored. b. Even newly inserted rows are stored in undo log. c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows. 2. Rows being read: a. A snapshot is stored in the undo log.
  • 47. Why is this important ? For every transaction: 1. Rows updated: a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored. b. Even newly inserted rows are stored in undo log. c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows. 2. Rows being read: a. A snapshot is stored in the undo log. b. It helps satisfy the isolation level of txn
  • 48. Why is this important ? For every transaction: 1. Rows updated: a. Before version of rows is stored in undo-log. If txn is rolled back, the before version is restored. b. Even newly inserted rows are stored in undo log. c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows. 2. Rows being read: a. A snapshot is stored in the undo log. b. It helps satisfy the isolation level of txn c. Once txn completes (rolled back/committed) , the undo log purges the relevant rows.
  • 49. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage.
  • 50. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage. ● Storage is shared across nodes ○ => a single undo log that is shared between writer & reader
  • 51. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage. ● Storage is shared across nodes ○ => a single undo log that is shared between writer & reader ● Imagine long running transactions
  • 52. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage. ● Storage is shared across nodes ○ => a single undo log that is shared between writer & reader ● Imagine long running transactions ○ Based on isolation level
  • 53. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage. ● Storage is shared across nodes ○ => a single undo log that is shared between writer & reader ● Imagine long running transactions ○ Based on isolation level ○ The undo log might keep growing …
  • 54. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage. ● Storage is shared across nodes ○ => a single undo log that is shared between writer & reader ● Imagine long running transactions ○ Based on isolation level ○ The undo log might keep growing … ○ Purging / garbage collection will not occur…
  • 55. Aurora Undo Log ● Normally in vanilla mysql, ○ each node has its own storage. ● Storage is shared across nodes ○ => a single undo log that is shared between writer & reader ● Imagine long running transactions ○ Based on isolation level ○ The undo log might keep growing … ○ Purging / garbage collection will not occur… ○ At some point, Paralysis due to overdue GC
  • 56. Writes to Aurora & Cost ● Keep an eye on IOPS ○ IOPS ++ == $ ++ ● Batch your writes if possible ● Compress your data before sending.
  • 57. 1. Mysql error log 2. Mysql slow query log 3. Metrics
  • 58. Monitoring 1. Never ignore mysql error logs. It might have something critical mentioned. Its your best friend ! 2. Can Enable slow query logs to keep track of slow running queries 3. Metrics a. Recommend Percona PMM (available metrics are graphed nicely) b. Buffer pool usage metrics c. Undo log history growth / RollbackSegmentHistoryListLength metric d. Insert latencies e. IOPS usage
  • 59. Aurora Parallel query 1. The only feature missing in other mysql variants. 2. Allows for parallelism in a select query
  • 60. Aurora Parallel query 1. The only feature missing in other mysql variants. 2. Allows for parallelism in a select query 3. Bypasses the in-memory buffer pool doing table scans on disk. :)
  • 61. Aurora Parallel query 1. The only feature missing in other mysql variants. 2. Allows for parallelism in a select query 3. Bypasses the in-memory buffer pool doing table scans on disk. :) a. => IOPS => $ :)
  • 62. Aurora Parallel query 1. The only feature missing in other mysql variants. 2. Allows for parallelism in a select query 3. Bypasses the in-memory buffer pool doing table scans on disk. :) a. => IOPS => $ :) 4. Supposedly good for your reporting queries
  • 63. Other helpful stuff 1. Use START TRANSACTION READ ONLY ; (less bookkeeping for readonly) 2. Run an explain on your query; be aware if index is used. a. Explains are not always accurate 3. Show process list; (i used to kill long running transactions/ sleeping transactions - no mercy :) ) 4. Show engine innodb status; 5. You have an index on group by columns but order by columns not in index ? 6. Joining 2 tables - think of 2 for loops (keep outer for loop short) 7. Query Cache - apparently works well in aurora ! (discouraged in rds/mysql)
  • 64. Finally ● Make 1 change at a time ○ Change ○ See effect ○ Make next change
  • 65. Finally ● Make 1 change at a time ○ Change ○ See effect ○ Make next change ● Keep an eye on $ cost
  • 66. Select QNS from you; select Thank you from me; Who am I ? Ex Mysql Guy at Flipkart / Data guy at Trustana linkedin.com/in/213vishnu/ mash213.wordpress.com/conferences/ https://twitter.com/sweetweet213