SlideShare a Scribd company logo
1 of 25
Download to read offline
7 (or so) Deadly Performance Sins
Martin Arrieta - Senior DBA @Percona
Same old Story
• We tend to get the same issues over and
over again
• Customers face similar challenges
• Some fixes are very easy and we need to
promote common knowledge
2
Let’s learn from others mistakes 3
Deadly Sin #1
More is not always better
4
• If 1 is good, 2 is better right?
• Lots of people resolve issues by throwing
more resources at it, this does not always
work
5
Overallocation of Memory
• People go hog wild on per session buffers like read_buffer,
read_rnd_buffer, join_buffer, and sort_buffer.
• What is the maximum amount of memory that MySQL can
use?:
• Per-session buffers * max connections
• + buffer pool size
• + key buffer size
• + some other buffers
6
Swapping is well known
• Most people know that swapping is bad, but
they still over-allocate memory
• Did you know disabling swap can be bad as well?
• TIP: Swappiness
• sudo sysctl -w vm.swappiness=1
• echo 1 > /proc/sys/vm/swappiness
7
More and More Indexes
• A lot of people is still indexing every column
• Waste Space
• Waste Memory
• Slow down inserts/updates/deletes
• Multi-key indexes are better than index
merges
8
Deadly Sin #2
Default Configurations
9
• Don't leave the my.cnf as default configs!
• MyISAM is the default storage engine on
<= 5.5.4
• I have seen companies spend tens of
thousands of dollars on big hardware but
not allocate memory to the database.
10
my.cnf
• Minimally set:
• InnoDB
• Buffer pool size
• Log size
• Transaction commit
• Key Buffer (still using MyISAM?)
• Query cache
11
my.cnf Parameters
• innodb_buffer_pool_size - Size of buffer pool
• innodb_log_file_size - Size of redo log
• innodb_flush_log_at_trx_commit - Flush
method
• key_buffer_size - Buffer for MyISAM index buffers
• query_cache_type and query_cache_size -
Query cache options
12
Deadly Sin #3
Using Too Much Space
13
How much data?
• What's this obsession with keeping data
forever?
• Purge your data! Is data from 1990
really needed?
• Summarize old data
• Do you need minute-by-minute or
hourly averages it is fine?
14
• There is a data Explosion going on
• Afraid to get rid of things
• Wasting space, just because we can
• Using tools that design the tables for
us.
15
Choosing the right data type
• Thin is always better!
• Smaller datatypes mean less storage per row on disk
• Less storage per row means faster retrieval of rows
• Less storage per row means more rows fit into
memory
• Size especially matters with InnoDB PK's! (more later)
• PK's are clustered indexes
• Every subsequent index contains the PK!
16
Large on Disk = Large on Memory
• For instance:
• 1M 8byte objects = 7.62MB of memory
• 1M 4byte objects = 3.81MB
• You could have saved 50% of your space
17
Integer data type 18
Deadly Sin #4
Not Understanding Indexing
19
Avoid the *solo* index on every column
• Too many indexes slow down inserts/updates
• Bloat disk and memory
• Index merges can happen in some cases, but
they are slower then multiple key indexes
• If the cardinality is bad, MySQL will ignore
them.
20
More on Indexes
• Remove redundant indexes
• KEY ( id ) and KEY ( id, type ) are
redundant!
• Order *does* matter
• (name, lastname) != (lastname, name)
• Run explain plan to see which indexes are
being used
21
GUID’s are *not* your friend
• GUID’s are 32 characters
• If your using utf8, thats 3bytes per character, or 96
bytes per guid
• In MySQL(InnoDB) the PK is duplicated in all
subsequent indexes
• 10 Million row table with 5 indexes would mean you
could potentially need 96bytes * 5 * 10 million rows
or about 4.5GB... using even a bigint (8 bytes )
instead would require about 400MB.
22
Deadly Sin #5
Bad backup strategy.
23
• Slave servers are NOT backups.
• Taking backups from slave? Are you
checking the data consistency?
• Do you test your backups regularly?
• Using only logical backups? Is your boss
happy with the time of the restore
process?
24
Questions?
25
martin.arrieta@percona.com
@MartinArrietaC

More Related Content

Similar to 7 (or so) deadly sins - PLMCE 2015

Building a CRM on top of ElasticSearch
Building a CRM on top of ElasticSearchBuilding a CRM on top of ElasticSearch
Building a CRM on top of ElasticSearchMark Greene
 
NYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentNYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentSpeedment, Inc.
 
Keeping MongoDB Data Safe
Keeping MongoDB Data SafeKeeping MongoDB Data Safe
Keeping MongoDB Data SafeTony Tam
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBAIrawan Soetomo
 
Putting Kafka Into Overdrive
Putting Kafka Into OverdrivePutting Kafka Into Overdrive
Putting Kafka Into OverdriveTodd Palino
 
High Performance With Java
High Performance With JavaHigh Performance With Java
High Performance With Javamalduarte
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL-Consulting
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]Speedment, Inc.
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]Malin Weiss
 
Column Stores and Google BigQuery
Column Stores and Google BigQueryColumn Stores and Google BigQuery
Column Stores and Google BigQueryCsaba Toth
 
Unit-II Memory Interfacing.pptx
Unit-II Memory Interfacing.pptxUnit-II Memory Interfacing.pptx
Unit-II Memory Interfacing.pptxpvg123456
 
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)Spark Summit
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017Ivan Zoratti
 
Riak at Posterous
Riak at PosterousRiak at Posterous
Riak at Posterouscapotej
 
Hadoop Operations: Keeping the Elephant Running Smoothly
Hadoop Operations: Keeping the Elephant Running SmoothlyHadoop Operations: Keeping the Elephant Running Smoothly
Hadoop Operations: Keeping the Elephant Running SmoothlyMichael Arnold
 
Improving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxImproving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxAlex Moundalexis
 
Responding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in JavaResponding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in JavaPeter Lawrey
 
What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010jbellis
 
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMsJava one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMsSpeedment, Inc.
 

Similar to 7 (or so) deadly sins - PLMCE 2015 (20)

Building a CRM on top of ElasticSearch
Building a CRM on top of ElasticSearchBuilding a CRM on top of ElasticSearch
Building a CRM on top of ElasticSearch
 
NYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentNYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ Speedment
 
Keeping MongoDB Data Safe
Keeping MongoDB Data SafeKeeping MongoDB Data Safe
Keeping MongoDB Data Safe
 
The 5 Minute MySQL DBA
The 5 Minute MySQL DBAThe 5 Minute MySQL DBA
The 5 Minute MySQL DBA
 
Running MySQL on Linux
Running MySQL on LinuxRunning MySQL on Linux
Running MySQL on Linux
 
Putting Kafka Into Overdrive
Putting Kafka Into OverdrivePutting Kafka Into Overdrive
Putting Kafka Into Overdrive
 
High Performance With Java
High Performance With JavaHigh Performance With Java
High Performance With Java
 
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya KosmodemianskyPostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
Column Stores and Google BigQuery
Column Stores and Google BigQueryColumn Stores and Google BigQuery
Column Stores and Google BigQuery
 
Unit-II Memory Interfacing.pptx
Unit-II Memory Interfacing.pptxUnit-II Memory Interfacing.pptx
Unit-II Memory Interfacing.pptx
 
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
Data Storage Tips for Optimal Spark Performance-(Vida Ha, Databricks)
 
MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017MySQL Performance Tuning London Meetup June 2017
MySQL Performance Tuning London Meetup June 2017
 
Riak at Posterous
Riak at PosterousRiak at Posterous
Riak at Posterous
 
Hadoop Operations: Keeping the Elephant Running Smoothly
Hadoop Operations: Keeping the Elephant Running SmoothlyHadoop Operations: Keeping the Elephant Running Smoothly
Hadoop Operations: Keeping the Elephant Running Smoothly
 
Improving Hadoop Performance via Linux
Improving Hadoop Performance via LinuxImproving Hadoop Performance via Linux
Improving Hadoop Performance via Linux
 
Responding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in JavaResponding rapidly when you have 100+ GB data sets in Java
Responding rapidly when you have 100+ GB data sets in Java
 
What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010What every developer should know about database scalability, PyCon 2010
What every developer should know about database scalability, PyCon 2010
 
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMsJava one2015 - Work With Hundreds of Hot Terabytes in JVMs
Java one2015 - Work With Hundreds of Hot Terabytes in JVMs
 

Recently uploaded

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Recently uploaded (20)

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 

7 (or so) deadly sins - PLMCE 2015

  • 1. 7 (or so) Deadly Performance Sins Martin Arrieta - Senior DBA @Percona
  • 2. Same old Story • We tend to get the same issues over and over again • Customers face similar challenges • Some fixes are very easy and we need to promote common knowledge 2
  • 3. Let’s learn from others mistakes 3
  • 4. Deadly Sin #1 More is not always better 4
  • 5. • If 1 is good, 2 is better right? • Lots of people resolve issues by throwing more resources at it, this does not always work 5
  • 6. Overallocation of Memory • People go hog wild on per session buffers like read_buffer, read_rnd_buffer, join_buffer, and sort_buffer. • What is the maximum amount of memory that MySQL can use?: • Per-session buffers * max connections • + buffer pool size • + key buffer size • + some other buffers 6
  • 7. Swapping is well known • Most people know that swapping is bad, but they still over-allocate memory • Did you know disabling swap can be bad as well? • TIP: Swappiness • sudo sysctl -w vm.swappiness=1 • echo 1 > /proc/sys/vm/swappiness 7
  • 8. More and More Indexes • A lot of people is still indexing every column • Waste Space • Waste Memory • Slow down inserts/updates/deletes • Multi-key indexes are better than index merges 8
  • 9. Deadly Sin #2 Default Configurations 9
  • 10. • Don't leave the my.cnf as default configs! • MyISAM is the default storage engine on <= 5.5.4 • I have seen companies spend tens of thousands of dollars on big hardware but not allocate memory to the database. 10
  • 11. my.cnf • Minimally set: • InnoDB • Buffer pool size • Log size • Transaction commit • Key Buffer (still using MyISAM?) • Query cache 11
  • 12. my.cnf Parameters • innodb_buffer_pool_size - Size of buffer pool • innodb_log_file_size - Size of redo log • innodb_flush_log_at_trx_commit - Flush method • key_buffer_size - Buffer for MyISAM index buffers • query_cache_type and query_cache_size - Query cache options 12
  • 13. Deadly Sin #3 Using Too Much Space 13
  • 14. How much data? • What's this obsession with keeping data forever? • Purge your data! Is data from 1990 really needed? • Summarize old data • Do you need minute-by-minute or hourly averages it is fine? 14
  • 15. • There is a data Explosion going on • Afraid to get rid of things • Wasting space, just because we can • Using tools that design the tables for us. 15
  • 16. Choosing the right data type • Thin is always better! • Smaller datatypes mean less storage per row on disk • Less storage per row means faster retrieval of rows • Less storage per row means more rows fit into memory • Size especially matters with InnoDB PK's! (more later) • PK's are clustered indexes • Every subsequent index contains the PK! 16
  • 17. Large on Disk = Large on Memory • For instance: • 1M 8byte objects = 7.62MB of memory • 1M 4byte objects = 3.81MB • You could have saved 50% of your space 17
  • 19. Deadly Sin #4 Not Understanding Indexing 19
  • 20. Avoid the *solo* index on every column • Too many indexes slow down inserts/updates • Bloat disk and memory • Index merges can happen in some cases, but they are slower then multiple key indexes • If the cardinality is bad, MySQL will ignore them. 20
  • 21. More on Indexes • Remove redundant indexes • KEY ( id ) and KEY ( id, type ) are redundant! • Order *does* matter • (name, lastname) != (lastname, name) • Run explain plan to see which indexes are being used 21
  • 22. GUID’s are *not* your friend • GUID’s are 32 characters • If your using utf8, thats 3bytes per character, or 96 bytes per guid • In MySQL(InnoDB) the PK is duplicated in all subsequent indexes • 10 Million row table with 5 indexes would mean you could potentially need 96bytes * 5 * 10 million rows or about 4.5GB... using even a bigint (8 bytes ) instead would require about 400MB. 22
  • 23. Deadly Sin #5 Bad backup strategy. 23
  • 24. • Slave servers are NOT backups. • Taking backups from slave? Are you checking the data consistency? • Do you test your backups regularly? • Using only logical backups? Is your boss happy with the time of the restore process? 24