SlideShare a Scribd company logo
MySQL PerformanceMySQL Performance
OptimizationOptimization
Presenter:
Avishek Kumar Sharma
Mindfire Solutions
Date: 16/04/2014
OCP MySQL 5.0 - Oracle Certified Professional
Connect Me :
Facebook: https://www.facebook.com/avishekkumar.sharma.5
LinkedIn: http://in.linkedin.com/pub/avishek-kumar-sharma/31/798/509
Twitter: https://twitter.com/sharma_avishek
Google+: https://plus.google.com/103775319893123886681/posts
Blog:
http://avisheksharma.wordpress.com
Contact Me :
Email: avisheks@mindfiresolutions.com / avishekk111@gmail.com
Skype: mfsi_avisheks
About Me
3
Today's Talk
1. Choose Correct engine
2. Data Types and Schema Design
3. Understanding Query Execution plan
4. Profiling
5. Role of Indexing
6. Optimizing GROUP BY/ORDER BY
7. Covering index
8. Scaling data
9. Conclusion
4
Choose Correct engine
“You should use InnoDB for your tables unless you have a compelling need to use a different
engine” - High Performance MySQL by Peter Zaitsev
MyISAM vs InnoDBMyISAM vs InnoDB
InnoDB:
Transaction Support, Crash-safe
Row Level locking
Mix for mix of Updates and Select Statements
MyISAM:
Best for Read-heavy applications
Doesn't scale very well when there are a lot of writes.
Memory:
Best for small sized temp summary table, low latency, non-persistent
InnoDB also support “Full Text Search” in MySQL 5.6
5
Data Types and Schema Design
1. Add `id` to each table ( id INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT)
2. Smaller sizes are usually better
3. Have a discussion on NULL VS blank VS 0. (choose not null for KEY
columns).
4. CHAR vs VARCHAR ( Space Vs Performance)
6
Data Types and Schema Design
5. ENUM : For storing strings values which have fixed and small sample
space use ENUM data type
6. Identifier for table joins should be of the same data type to
improve performance by reducing type conversion.
7. Normalization vs Denormalization (Faster Joins Vs Redundencies)
7
Have a look what procedure analyse() 's saying.
MySQLClint(DB:as_01):select id from dochead procedure analyse()G
*************************** 1. row ***************************
Field_name: as_01.dochead.id
Min_value: 1
Max_value: 11294
Min_length: 1
Max_length: 5
Empties_or_zeros: 0
Nulls: 0
Avg_value_or_avg_length: 5678.8494
Std: 3270.5730
Optimal_fieldtype: SMALLINT(5) UNSIGNED NOT NULL
1 row in set (0.01 sec)
This is what MySQL suggesting
the datatype to be
8
Query Execution Plan
Using the EXPLAIN keyword can give you insight on what
MySQL is doing to execute your query.
Eg: explain select col1 from <table_name> where col2=123 group by col3 order by col3;
9
Explain some field values
Some of the important columns we gonna consider are:
●
type: const, eq_ref, ref, fulltext, range, index, ALL(sort order by speed)
●
possible_keys: all the candicates for the query
●
key: selected index (could be more than one)
●
key_len: index length (agg for composite indexes)
●
rows: no of approximate rows traversal
●
extra: using filesort, using index, using temporary,using where
10
SET Profiling=ON
Profiling helps us analysing query resources
●
mysql> SET profiling=1;
●
mysql> run your query....
●
mysql> SHOW profiles;
●
mysql> SHOW profile [CPU] FOR QUERY 1;
11
Role of Indexing
Index optimization is perhaps the most powerful way to
improve query performance.
When performance problems occur:
– Add indexes
– Rewrite your queries
– Or both
Do you need to fetch data (often on disk) ?
– If the index contains the data, you don't
– If you don't, your query is covered by an index (=index-only
query)
12
Isolating the Column
MySQL generally can’t use indexes on columns unless the
columns are isolated in the query. “Isolating” the column means
it should not be part of an expression or be inside a function in
the query.
Wrong:
– mysql> SELECT actor_id FROM sakila.actor WHERE actor_id + 1 = 5;
Correct:
– mysql> SELECT actor_id FROM sakila.actor WHERE actor_id = 4;
13
Keep queries deterministic(Query Cache)
Since the return result of the function can change, MySQL
decides to disable query caching for that query.
// query cache does NOT work
$r = mysql_query("SELECT username FROM user WHERE signup_date >=
CURDATE()");
// query cache works!
$today = date("Y-m-d");
$r = mysql_query("SELECT username FROM user WHERE signup_date >=
'$today'");
NB: This applies to all non-deterministic functions like NOW() and RAND() etc
14
Column Prefix Indexes
● Smaller is usually better for obvious reasons
● Allow index BLOB/TEXT columns
CREATE TABLE user_address(
`id` INT UNSIGNED
...
...
`address` varchar(255)
PRIMARY KEY(`id`)
)
Eg: CREATE INDEX part_of_address ON user_address(address(10));
15
Choose correct prefix length
● Check the full selectivity of your column.
● Check selectivity of several prefix lengths.
16
Here we go
● Choose the prefix length having almost the same selectivity with
the full column selectivity. In the example, prefix length 7
selectivity is almost the same with the full column
selectivity so we will used it as the index.
● Create prefix indexes.
17
Optimize GROUP BY/ORDER BY
● GROUP BY and ORDER BY queries do post-retrieval
work
● GROUP BY compels to create “Temp Table”
● and ORDER BY “File Sort”
● Indexing can help get rid of this work.
18
Ignore GROUP BY sorting
● GROUP BY does implicit sorting
MySQLClint(DB:as_01)>
EXPLAIN
SELECT DISTINCT c.id,legal_name
FROM contractor c
JOIN dochead dh ON c.id=dh.contractor_to
WHERE
dh.system_id=623
AND invoice.doc_type=”invoice”
GROUP BY c.id
ORDER BY nullG
19
Check EXPLAIN's Extra
*************************** 1. row ***************************
id: 1
type: ref
....
possible_keys: dochead_contractor_to,dochead_system_id
key: dochead_system_id
key_len: 4
ref: const
rows: 306
Extra: Using where; Using temporary; Using filesort
20
Check EXPLAIN's Changes
*************************** 1. row ***************************
id: 1
type: ref
....
....
possible_keys: dochead_contractor_to,dochead_system_id
key: dochead_system_id
key_len: 4
ref: const
rows: 306
Extra: Using where; Using temporary; Using filesort
Using file sort will be vanished if
we dont bother for ordering
21
Sometimes derived tables help
● Logic is less amount of data rows has to be traverse
● Filter results by cheapest first
● Limitation is Indexes cannot be used, and it has to be less
row size.
22
Covering Index
● Indexes need to be designed for the whole query, not
just the WHERE clause. Contains (or “covers”) all the
data needed to satisfy a query.
Query with traditional index:Query with traditional index:
– Get right rows with indexGet right rows with index
– Get data from rowsGet data from rows
– Send data back to clientSend data back to client
Index-covered query:Index-covered query:
– Get right rows with indexGet right rows with index
– Get data from rowsGet data from rows
– Send data back to clientSend data back to client
23
Case Study
SELECT sum(value)SELECT sum(value)
FROM Table1FROM Table1
WHERE item_id=? AND category_id = ?WHERE item_id=? AND category_id = ?
GROUP BY customer_id;GROUP BY customer_id;
ALTER TABLE Table1ALTER TABLE Table1
ADD INDEX t1_index(item_id,category_id,customer_id,value)ADD INDEX t1_index(item_id,category_id,customer_id,value)
24
Check if used covering index
mysql> EXPLAIN SELECT sum(value)
FROM Table1
WHERE item_id=? AND category_id = ?
GROUP BY customer_id;
*************************** 1. row ***************************
table: Table1
.....
possible_keys: t1_index
key: t1_index
Extra: Using where;Using index
This signs that query used
covering index.
25
Column Order in Covering Index
1. Const or equality
WHERE a = 5
2. Range
WHERE a = 5 AND b > 5
3. Order or Group By
WHERE a = 5 AND b > 5 GROUP BY c
WHERE a = 5 AND b > 5 ORDER BY c DESC
4. Select
count(d), sum(d)
26
Lets put all together(Scaling)
●
Analyse explain and keep on trying/improving
– STRAIGHT_JOIN,
– FORCE INDEX/USE INDEX,
– IGNORE INDEX
●
Memory/Disk/CPU/Network
●
Upgrade MySQL Server
●
Move to Amazon RDS
– I strongly recommend, have personal experience
27
Thank you :)Thank you :)
28
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
http://twitter.com/mindfires
www.mindfiresolutions.com
Contact Us @

More Related Content

PDF
MySQL: Indexing for Better Performance
PPT
Explain that explain
PPTX
Optimizing MySQL Queries
PDF
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
PDF
Mysql Explain Explained
PDF
MySQL Query And Index Tuning
PPTX
Sql killedserver
PPTX
How mysql choose the execution plan
MySQL: Indexing for Better Performance
Explain that explain
Optimizing MySQL Queries
MySQL Indexing : Improving Query Performance Using Index (Covering Index)
Mysql Explain Explained
MySQL Query And Index Tuning
Sql killedserver
How mysql choose the execution plan

What's hot (20)

PDF
How to analyze and tune sql queries for better performance percona15
PDF
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
PPTX
MySQL Indexes
PDF
TSQL Coding Guidelines
PDF
How to analyze and tune sql queries for better performance webinar
PDF
How to Analyze and Tune MySQL Queries for Better Performance
PPTX
Lab5 sub query
PPTX
MySQL index optimization techniques
PDF
How to analyze and tune sql queries for better performance vts2016
PPTX
Chapter 4 functions, views, indexing
PPTX
Trigger in mysql
PDF
How to Analyze and Tune MySQL Queries for Better Performance
PDF
MySQL Index Cookbook
PDF
Database development coding standards
PPTX
Query parameterization
PPTX
MySQL Indexing - Best practices for MySQL 5.6
RTF
Mysql joins example table and query process
PPTX
MySQL basics
PPT
A testing framework for Microsoft SQL-Server
PDF
Sql db optimization
How to analyze and tune sql queries for better performance percona15
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
MySQL Indexes
TSQL Coding Guidelines
How to analyze and tune sql queries for better performance webinar
How to Analyze and Tune MySQL Queries for Better Performance
Lab5 sub query
MySQL index optimization techniques
How to analyze and tune sql queries for better performance vts2016
Chapter 4 functions, views, indexing
Trigger in mysql
How to Analyze and Tune MySQL Queries for Better Performance
MySQL Index Cookbook
Database development coding standards
Query parameterization
MySQL Indexing - Best practices for MySQL 5.6
Mysql joins example table and query process
MySQL basics
A testing framework for Microsoft SQL-Server
Sql db optimization
Ad

Similar to MySQL Performance Optimization (20)

PPTX
My SQL Skills Killed the Server
PDF
Introduction to Databases - query optimizations for MySQL
ODP
SQL Tunning
PDF
Mysql Optimization
PPTX
MySQL performance tuning
PDF
Advanced MySQL Query Optimizations
PDF
Presentation interpreting execution plans for sql statements
PPT
Overview of query evaluation
PPTX
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PPTX
HPD SQL Training - Beginner - 20220916.pptx
PDF
Query Optimization with MySQL 5.6: Old and New Tricks
PPTX
My Database Skills Killed the Server
PDF
Goldilocks and the Three MySQL Queries
PDF
PostgreSQL High_Performance_Cheatsheet
PPTX
MongoDB.local DC 2018: Tips and Tricks for Avoiding Common Query Pitfalls
PPTX
Tunning sql query
PDF
Sql Server Query Parameterization
PPTX
Confoo 2021 - MySQL Indexes & Histograms
PPTX
Database Performance Tuning
PDF
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
My SQL Skills Killed the Server
Introduction to Databases - query optimizations for MySQL
SQL Tunning
Mysql Optimization
MySQL performance tuning
Advanced MySQL Query Optimizations
Presentation interpreting execution plans for sql statements
Overview of query evaluation
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
HPD SQL Training - Beginner - 20220916.pptx
Query Optimization with MySQL 5.6: Old and New Tricks
My Database Skills Killed the Server
Goldilocks and the Three MySQL Queries
PostgreSQL High_Performance_Cheatsheet
MongoDB.local DC 2018: Tips and Tricks for Avoiding Common Query Pitfalls
Tunning sql query
Sql Server Query Parameterization
Confoo 2021 - MySQL Indexes & Histograms
Database Performance Tuning
Dutch PHP Conference 2021 - MySQL Indexes and Histograms
Ad

More from Mindfire Solutions (20)

PDF
Physician Search and Review
PDF
diet management app
PDF
Business Technology Solution
PDF
Remote Health Monitoring
PDF
Influencer Marketing Solution
PPT
High Availability of Azure Applications
PPTX
IOT Hands On
PPTX
Glimpse of Loops Vs Set
ODP
Oracle Sql Developer-Getting Started
PPT
Adaptive Layout In iOS 8
PPT
Introduction to Auto-layout : iOS/Mac
PPT
LINQPad - utility Tool
PPT
Get started with watch kit development
PPTX
Swift vs Objective-C
ODP
Material Design in Android
ODP
Introduction to OData
PPT
Ext js Part 2- MVC
PPT
ExtJs Basic Part-1
PPT
Spring Security Introduction
Physician Search and Review
diet management app
Business Technology Solution
Remote Health Monitoring
Influencer Marketing Solution
High Availability of Azure Applications
IOT Hands On
Glimpse of Loops Vs Set
Oracle Sql Developer-Getting Started
Adaptive Layout In iOS 8
Introduction to Auto-layout : iOS/Mac
LINQPad - utility Tool
Get started with watch kit development
Swift vs Objective-C
Material Design in Android
Introduction to OData
Ext js Part 2- MVC
ExtJs Basic Part-1
Spring Security Introduction

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Transform Your Business with a Software ERP System
PDF
medical staffing services at VALiNTRY
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
top salesforce developer skills in 2025.pdf
PDF
AI in Product Development-omnex systems
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
history of c programming in notes for students .pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
ai tools demonstartion for schools and inter college
PPTX
L1 - Introduction to python Backend.pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
Design an Analysis of Algorithms I-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Odoo POS Development Services by CandidRoot Solutions
PTS Company Brochure 2025 (1).pdf.......
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Transform Your Business with a Software ERP System
medical staffing services at VALiNTRY
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
top salesforce developer skills in 2025.pdf
AI in Product Development-omnex systems
Understanding Forklifts - TECH EHS Solution
Design an Analysis of Algorithms II-SECS-1021-03
history of c programming in notes for students .pptx
Wondershare Filmora 15 Crack With Activation Key [2025
ai tools demonstartion for schools and inter college
L1 - Introduction to python Backend.pptx
Odoo Companies in India – Driving Business Transformation.pdf
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
Design an Analysis of Algorithms I-SECS-1021-03

MySQL Performance Optimization

  • 2. OCP MySQL 5.0 - Oracle Certified Professional Connect Me : Facebook: https://www.facebook.com/avishekkumar.sharma.5 LinkedIn: http://in.linkedin.com/pub/avishek-kumar-sharma/31/798/509 Twitter: https://twitter.com/sharma_avishek Google+: https://plus.google.com/103775319893123886681/posts Blog: http://avisheksharma.wordpress.com Contact Me : Email: avisheks@mindfiresolutions.com / avishekk111@gmail.com Skype: mfsi_avisheks About Me
  • 3. 3 Today's Talk 1. Choose Correct engine 2. Data Types and Schema Design 3. Understanding Query Execution plan 4. Profiling 5. Role of Indexing 6. Optimizing GROUP BY/ORDER BY 7. Covering index 8. Scaling data 9. Conclusion
  • 4. 4 Choose Correct engine “You should use InnoDB for your tables unless you have a compelling need to use a different engine” - High Performance MySQL by Peter Zaitsev MyISAM vs InnoDBMyISAM vs InnoDB InnoDB: Transaction Support, Crash-safe Row Level locking Mix for mix of Updates and Select Statements MyISAM: Best for Read-heavy applications Doesn't scale very well when there are a lot of writes. Memory: Best for small sized temp summary table, low latency, non-persistent InnoDB also support “Full Text Search” in MySQL 5.6
  • 5. 5 Data Types and Schema Design 1. Add `id` to each table ( id INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT) 2. Smaller sizes are usually better 3. Have a discussion on NULL VS blank VS 0. (choose not null for KEY columns). 4. CHAR vs VARCHAR ( Space Vs Performance)
  • 6. 6 Data Types and Schema Design 5. ENUM : For storing strings values which have fixed and small sample space use ENUM data type 6. Identifier for table joins should be of the same data type to improve performance by reducing type conversion. 7. Normalization vs Denormalization (Faster Joins Vs Redundencies)
  • 7. 7 Have a look what procedure analyse() 's saying. MySQLClint(DB:as_01):select id from dochead procedure analyse()G *************************** 1. row *************************** Field_name: as_01.dochead.id Min_value: 1 Max_value: 11294 Min_length: 1 Max_length: 5 Empties_or_zeros: 0 Nulls: 0 Avg_value_or_avg_length: 5678.8494 Std: 3270.5730 Optimal_fieldtype: SMALLINT(5) UNSIGNED NOT NULL 1 row in set (0.01 sec) This is what MySQL suggesting the datatype to be
  • 8. 8 Query Execution Plan Using the EXPLAIN keyword can give you insight on what MySQL is doing to execute your query. Eg: explain select col1 from <table_name> where col2=123 group by col3 order by col3;
  • 9. 9 Explain some field values Some of the important columns we gonna consider are: ● type: const, eq_ref, ref, fulltext, range, index, ALL(sort order by speed) ● possible_keys: all the candicates for the query ● key: selected index (could be more than one) ● key_len: index length (agg for composite indexes) ● rows: no of approximate rows traversal ● extra: using filesort, using index, using temporary,using where
  • 10. 10 SET Profiling=ON Profiling helps us analysing query resources ● mysql> SET profiling=1; ● mysql> run your query.... ● mysql> SHOW profiles; ● mysql> SHOW profile [CPU] FOR QUERY 1;
  • 11. 11 Role of Indexing Index optimization is perhaps the most powerful way to improve query performance. When performance problems occur: – Add indexes – Rewrite your queries – Or both Do you need to fetch data (often on disk) ? – If the index contains the data, you don't – If you don't, your query is covered by an index (=index-only query)
  • 12. 12 Isolating the Column MySQL generally can’t use indexes on columns unless the columns are isolated in the query. “Isolating” the column means it should not be part of an expression or be inside a function in the query. Wrong: – mysql> SELECT actor_id FROM sakila.actor WHERE actor_id + 1 = 5; Correct: – mysql> SELECT actor_id FROM sakila.actor WHERE actor_id = 4;
  • 13. 13 Keep queries deterministic(Query Cache) Since the return result of the function can change, MySQL decides to disable query caching for that query. // query cache does NOT work $r = mysql_query("SELECT username FROM user WHERE signup_date >= CURDATE()"); // query cache works! $today = date("Y-m-d"); $r = mysql_query("SELECT username FROM user WHERE signup_date >= '$today'"); NB: This applies to all non-deterministic functions like NOW() and RAND() etc
  • 14. 14 Column Prefix Indexes ● Smaller is usually better for obvious reasons ● Allow index BLOB/TEXT columns CREATE TABLE user_address( `id` INT UNSIGNED ... ... `address` varchar(255) PRIMARY KEY(`id`) ) Eg: CREATE INDEX part_of_address ON user_address(address(10));
  • 15. 15 Choose correct prefix length ● Check the full selectivity of your column. ● Check selectivity of several prefix lengths.
  • 16. 16 Here we go ● Choose the prefix length having almost the same selectivity with the full column selectivity. In the example, prefix length 7 selectivity is almost the same with the full column selectivity so we will used it as the index. ● Create prefix indexes.
  • 17. 17 Optimize GROUP BY/ORDER BY ● GROUP BY and ORDER BY queries do post-retrieval work ● GROUP BY compels to create “Temp Table” ● and ORDER BY “File Sort” ● Indexing can help get rid of this work.
  • 18. 18 Ignore GROUP BY sorting ● GROUP BY does implicit sorting MySQLClint(DB:as_01)> EXPLAIN SELECT DISTINCT c.id,legal_name FROM contractor c JOIN dochead dh ON c.id=dh.contractor_to WHERE dh.system_id=623 AND invoice.doc_type=”invoice” GROUP BY c.id ORDER BY nullG
  • 19. 19 Check EXPLAIN's Extra *************************** 1. row *************************** id: 1 type: ref .... possible_keys: dochead_contractor_to,dochead_system_id key: dochead_system_id key_len: 4 ref: const rows: 306 Extra: Using where; Using temporary; Using filesort
  • 20. 20 Check EXPLAIN's Changes *************************** 1. row *************************** id: 1 type: ref .... .... possible_keys: dochead_contractor_to,dochead_system_id key: dochead_system_id key_len: 4 ref: const rows: 306 Extra: Using where; Using temporary; Using filesort Using file sort will be vanished if we dont bother for ordering
  • 21. 21 Sometimes derived tables help ● Logic is less amount of data rows has to be traverse ● Filter results by cheapest first ● Limitation is Indexes cannot be used, and it has to be less row size.
  • 22. 22 Covering Index ● Indexes need to be designed for the whole query, not just the WHERE clause. Contains (or “covers”) all the data needed to satisfy a query. Query with traditional index:Query with traditional index: – Get right rows with indexGet right rows with index – Get data from rowsGet data from rows – Send data back to clientSend data back to client Index-covered query:Index-covered query: – Get right rows with indexGet right rows with index – Get data from rowsGet data from rows – Send data back to clientSend data back to client
  • 23. 23 Case Study SELECT sum(value)SELECT sum(value) FROM Table1FROM Table1 WHERE item_id=? AND category_id = ?WHERE item_id=? AND category_id = ? GROUP BY customer_id;GROUP BY customer_id; ALTER TABLE Table1ALTER TABLE Table1 ADD INDEX t1_index(item_id,category_id,customer_id,value)ADD INDEX t1_index(item_id,category_id,customer_id,value)
  • 24. 24 Check if used covering index mysql> EXPLAIN SELECT sum(value) FROM Table1 WHERE item_id=? AND category_id = ? GROUP BY customer_id; *************************** 1. row *************************** table: Table1 ..... possible_keys: t1_index key: t1_index Extra: Using where;Using index This signs that query used covering index.
  • 25. 25 Column Order in Covering Index 1. Const or equality WHERE a = 5 2. Range WHERE a = 5 AND b > 5 3. Order or Group By WHERE a = 5 AND b > 5 GROUP BY c WHERE a = 5 AND b > 5 ORDER BY c DESC 4. Select count(d), sum(d)
  • 26. 26 Lets put all together(Scaling) ● Analyse explain and keep on trying/improving – STRAIGHT_JOIN, – FORCE INDEX/USE INDEX, – IGNORE INDEX ● Memory/Disk/CPU/Network ● Upgrade MySQL Server ● Move to Amazon RDS – I strongly recommend, have personal experience