SlideShare a Scribd company logo
MySQL Performance Talk
May 29 2012
Eli Aschkenasy
@EliAschkenasy
Check list
 DB engine selection
Engines:
MyISAM vs. INNODB
Source: Oracle Jan, 2011
Source: Oracle Jan, 2011
Source: Oracle Jan, 2011
Source: Oracle Jan, 2011
Source: Google (google fix) 1Q, 2010
Check list
 DB engine selection
 Server update
Source: Giuseppe Maxia - MySQL Community Team Lead 1Q, 2010
Source: Giuseppe Maxia - MySQL Community Team Lead 1Q, 2010
Source: Giuseppe Maxia - MySQL Community Team Lead 1Q, 2010
Bottom line:
Newer ISbetter
Check list
 DB engine selection
 Server update
 Data types
Data Types Rules:
 Smaller is better (usually)
 Avoid NULL if possible (index/comparison)
 Don’t forget about TINYINT and (UN)SIGNED
 ALL INT calculations create 64bit BIGINT (storage is the only difference)
 Width identifier is meaningless – INT(1) occupies the same space as INT(20)
 VARCHAR vs. CHAR – fixed allocation of space (CHAR)
 Downside of VARCHAR is that the row might grow.
 BLOB and TEXT are identical other than collation and character set information
 ENUM
Data Types Rules:
Data Types Rules:
 Smaller is better (usually)
 Avoid NULL if possible (index/comparison)
 Don’t forget about TINYINT and (UN)SIGNED
 ALL INT calculations create 64bit BIGINT (storage is the only difference)
 Width identifier is meaningless – INT(1) occupies the same space as INT(20)
 VARCHAR vs. CHAR – fixed allocation of space (CHAR)
 Downside of VARCHAR is that the row might grow.
 BLOB and TEXT are identical other than collation and character set information
 ENUM (Don’t use)
 DATE vs. DATETIME
Check list
 DB engine selection
 Server update
 Data types
 Counter tables
mysql > SELECT COUNT(*) FROM asset_table;
mysql > CREATE TABLE asset_counter (
cnt INT UNSIGNED NOT NULL
) ENGINE=InnoDB;
On addition:
UPDATE asset_counter SET cnt = cnt+1;
mysql > CREATE TABLE asset_counter (
slot TINYINT UNSIGNED NOT NULL PRIMARY KEY,
cnt INT UNSIGNED NOT NULL
) ENGINE=InnoDB;
Pre-populate 100 rows (slot will be 1 – 100)
On addition:
UPDATE asset_counter SET cnt = cnt+1 WHERE slot = RAND() * 100;
Check list
 DB engine selection
 Server update
 Data types
 Counter tables
 Indexing (even for ORMs)
Indexing 1: hash – (for lookup tables)
InnoDB creates this automatically for frequently accessed index values.
Indexing 2: selectivity – (multi column indexes)
Check list
 DB engine selection
 Server update
 Data types
 Counter tables
 Indexing (even for ORMs)
 Query optimization
Query optimization:
Optimize data AMOUNT
Use Limit in your Query (instead of the application code)
Deadly * - Do you really need ALL data from a row ?!?
Double data – same resource in multiple queries
Reduce DB workload
Use Indexes!
Use a covering index (remember selectivity?)
Complex query vs. Many simple queries
Query optimization:
Query optimization:
Query optimization:
Bottom (bottom) line:
Always check real data!

More Related Content

PDF
Php + MySql Optimization
PPTX
Feeding automated test by Joe Beale
PPTX
Ml study notes linq
PPTX
Linked list
PPTX
Singly Linked List
ODP
Java - Collections
PPTX
2CPP13 - Operator Overloading
PPTX
Dynamic memory allocation and linked lists
Php + MySql Optimization
Feeding automated test by Joe Beale
Ml study notes linq
Linked list
Singly Linked List
Java - Collections
2CPP13 - Operator Overloading
Dynamic memory allocation and linked lists

What's hot (12)

PPT
Stacks
PDF
Cubes – ways of deployment
PPTX
Pandas
PDF
InfiniFlux Minmax Cache
PPTX
Database index
PPTX
ArrayList in JAVA
PDF
The List Data Model
PPTX
Array vs array list
PDF
Chunked, dplyr for large text files
PPTX
Java Tutorial Lab 7
PPTX
Data structure
PDF
Docopt, beautiful command-line options for R, user2014
Stacks
Cubes – ways of deployment
Pandas
InfiniFlux Minmax Cache
Database index
ArrayList in JAVA
The List Data Model
Array vs array list
Chunked, dplyr for large text files
Java Tutorial Lab 7
Data structure
Docopt, beautiful command-line options for R, user2014
Ad

Similar to MySQL Performance Optimization #NEOJUG12 (20)

PPT
Cost Based Optimizer - Part 1 of 2
PDF
MySQL Indexing
PPT
MongoDB @ fliptop
DOCX
PPTX
Database Performance
PPTX
unit 1 ppt.pptx
PPTX
Maryna Popova "Deep dive AWS Redshift"
PPTX
Tunning sql query
PPT
15 Ways to Kill Your Mysql Application Performance
PPTX
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
PPTX
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
PPT
Geek Austin PHP Class - Session 4
PPT
PO WER - Piotr Mariat - Sql
PPT
Database Application for La Salle
PDF
MariaDB Optimizer
PPT
MS SQL Server.ppt sql
PDF
Sql query tips or query optimization
PPTX
7. SQL.pptx
PPTX
GROUP-4-Database-Connectivity-with-MySqL.pptx
PPT
Indexing
Cost Based Optimizer - Part 1 of 2
MySQL Indexing
MongoDB @ fliptop
Database Performance
unit 1 ppt.pptx
Maryna Popova "Deep dive AWS Redshift"
Tunning sql query
15 Ways to Kill Your Mysql Application Performance
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
unit 1_unit1_unit1_unit 1_unit1_unit1_ ppt.pptx
Geek Austin PHP Class - Session 4
PO WER - Piotr Mariat - Sql
Database Application for La Salle
MariaDB Optimizer
MS SQL Server.ppt sql
Sql query tips or query optimization
7. SQL.pptx
GROUP-4-Database-Connectivity-with-MySqL.pptx
Indexing
Ad

Recently uploaded (20)

PPTX
CHAPTER 2 - PM Management and IT Context
PDF
top salesforce developer skills in 2025.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Introduction to Artificial Intelligence
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
System and Network Administraation Chapter 3
PPTX
history of c programming in notes for students .pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
System and Network Administration Chapter 2
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
CHAPTER 2 - PM Management and IT Context
top salesforce developer skills in 2025.pdf
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Introduction to Artificial Intelligence
Navsoft: AI-Powered Business Solutions & Custom Software Development
VVF-Customer-Presentation2025-Ver1.9.pptx
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administraation Chapter 3
history of c programming in notes for students .pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
System and Network Administration Chapter 2
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
2025 Textile ERP Trends: SAP, Odoo & Oracle
How to Migrate SBCGlobal Email to Yahoo Easily
Operating system designcfffgfgggggggvggggggggg
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

MySQL Performance Optimization #NEOJUG12

  • 1. MySQL Performance Talk May 29 2012 Eli Aschkenasy @EliAschkenasy
  • 2. Check list  DB engine selection
  • 8. Source: Google (google fix) 1Q, 2010
  • 9. Check list  DB engine selection  Server update
  • 10. Source: Giuseppe Maxia - MySQL Community Team Lead 1Q, 2010
  • 11. Source: Giuseppe Maxia - MySQL Community Team Lead 1Q, 2010
  • 12. Source: Giuseppe Maxia - MySQL Community Team Lead 1Q, 2010
  • 14. Check list  DB engine selection  Server update  Data types
  • 15. Data Types Rules:  Smaller is better (usually)  Avoid NULL if possible (index/comparison)  Don’t forget about TINYINT and (UN)SIGNED  ALL INT calculations create 64bit BIGINT (storage is the only difference)  Width identifier is meaningless – INT(1) occupies the same space as INT(20)  VARCHAR vs. CHAR – fixed allocation of space (CHAR)  Downside of VARCHAR is that the row might grow.  BLOB and TEXT are identical other than collation and character set information  ENUM
  • 17. Data Types Rules:  Smaller is better (usually)  Avoid NULL if possible (index/comparison)  Don’t forget about TINYINT and (UN)SIGNED  ALL INT calculations create 64bit BIGINT (storage is the only difference)  Width identifier is meaningless – INT(1) occupies the same space as INT(20)  VARCHAR vs. CHAR – fixed allocation of space (CHAR)  Downside of VARCHAR is that the row might grow.  BLOB and TEXT are identical other than collation and character set information  ENUM (Don’t use)  DATE vs. DATETIME
  • 18. Check list  DB engine selection  Server update  Data types  Counter tables
  • 19. mysql > SELECT COUNT(*) FROM asset_table; mysql > CREATE TABLE asset_counter ( cnt INT UNSIGNED NOT NULL ) ENGINE=InnoDB; On addition: UPDATE asset_counter SET cnt = cnt+1; mysql > CREATE TABLE asset_counter ( slot TINYINT UNSIGNED NOT NULL PRIMARY KEY, cnt INT UNSIGNED NOT NULL ) ENGINE=InnoDB; Pre-populate 100 rows (slot will be 1 – 100) On addition: UPDATE asset_counter SET cnt = cnt+1 WHERE slot = RAND() * 100;
  • 20. Check list  DB engine selection  Server update  Data types  Counter tables  Indexing (even for ORMs)
  • 21. Indexing 1: hash – (for lookup tables) InnoDB creates this automatically for frequently accessed index values.
  • 22. Indexing 2: selectivity – (multi column indexes)
  • 23. Check list  DB engine selection  Server update  Data types  Counter tables  Indexing (even for ORMs)  Query optimization
  • 24. Query optimization: Optimize data AMOUNT Use Limit in your Query (instead of the application code) Deadly * - Do you really need ALL data from a row ?!? Double data – same resource in multiple queries Reduce DB workload Use Indexes! Use a covering index (remember selectivity?) Complex query vs. Many simple queries
  • 28. Bottom (bottom) line: Always check real data!