Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DOs and DON'Ts of MySQL Performance
Search
TheBerg
July 10, 2014
Technology
5
160
DOs and DON'Ts of MySQL Performance
TheBerg
July 10, 2014
Tweet
Share
Other Decks in Technology
See All in Technology
コミュニティが変えるキャリアの地平線:コロナ禍新卒入社のエンジニアがAWSコミュニティで見つけた成長の羅針盤
kentosuzuki
0
130
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
2
3.1k
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
680
【Ubie】AIを活用した広告アセット「爆速」生成事例 | AI_Ops_Community_Vol.2
yoshiki_0316
1
120
AI駆動開発を事業のコアに置く
tasukuonizawa
1
360
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
180
~Everything as Codeを諦めない~ 後からCDK
mu7889yoon
3
480
Oracle AI Database移行・アップグレード勉強会 - RAT活用編
oracle4engineer
PRO
0
110
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
530
ブロックテーマでサイトをリニューアルした話 / 2026-01-31 Kansai WordPress Meetup
torounit
0
480
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
0
240
Building Flexible Design Systems
yeseniaperezcruz
330
40k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
Chasing Engaging Ingredients in Design
codingconduct
0
110
Abbi's Birthday
coloredviolet
1
4.8k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
52
Are puppies a ranking factor?
jonoalderson
1
2.7k
From π to Pie charts
rasagy
0
130
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Faster Mobile Websites
deanohume
310
31k
Automating Front-end Workflow
addyosmani
1371
200k
Transcript
DOs DON’Ts of MySQL Performance and
BERG developer JEFF planning center
data centers of data years 3 191GB 8 rows >750M
DO USE MySQL
its solid
everyone uses it
DON’T BE BLIND
monitor it
scout
newrelic
newrelic
DO USE INDEXES
when? • On almost every column ending in _id •
On any column in WHERE, GROUP or ORDER • Be careful about adding too many
left to right Index: first_name, last_name Query: SELECT *
FROM people WHERE first_name = ‘Jeff’ AND last_name = ‘Berg’
left to right Index: first_name, last_name Query: SELECT *
FROM people WHERE last_name = ‘Berg’ AND first_name = ‘Jeff’
left to right Index: first_name, last_name Query: SELECT *
FROM people WHERE first_name = ‘Jeff’
left to right Index: first_name, last_name Query: SELECT *
FROM people WHERE last_name = ‘Jeff’
DON’T USE LIKE WRONG
don’t use like wrong Index: first_name, last_name Query: SELECT
* FROM people WHERE phone_number LIKE ‘760%’
don’t use like wrong Index: first_name, last_name Query: SELECT
* FROM people WHERE phone_number LIKE ‘%1234’
DO USE EXPLAIN & PROFILE
do use explain EXPLAIN SELECT * FROM ccli_songs WHERE title
LIKE ‘query%’
do use explain EXPLAIN SELECT * FROM ccli_songs WHERE title
LIKE ‘%query%’
do use profiling SET PROFILING = 1; ! SELECT *
FROM ccli_songs WHERE title LIKE ‘Title%'; ! SHOW PROFILE;
DON’T PAGINATE
don’t paginate SELECT * from people LIMIT 100 OFFSET
100000; Query Time: 699ms
don’t paginate SELECT * from people WHERE id > 4560177
LIMIT 100; Query Time: 60ms
DO CHECK YOUR CONFIGURATION
check your config innodb_buffer_pool_size, innodb_log_file_size, max_connections, innodb_file_per_table, innodb_flush_log_at_trx_commit, innodb_flush_method, innodb_log_buffer_size,
query_cache_size, log_bin, skip_name_resolve http://www.mysqlperformanceblog.com/2014/01/28/10-mysql-settings-to-tune-after-installation/
DON’T MESS UP PRIMARY KEYS
primary keys • data is organized via primary key •
integer auto increment primary key puts rows on disk in order created • UUID primary key puts rows in random order • combined PK, puts items in order grouped
primary keys Primary Key: id
primary keys Primary Key: organization_id, id
DO HAVE THE RIGHT HARDWARE
the right hardware • SSDs are worth their weight in
gold • Try to have enough RAM to hold your whole database in memory
DON’T USE MySQL
don’t use mysql • use percona server or maria db
• many Google & Facebook patches applied • many percona ideas • ran by many of original mysql team after oracle acquisition
don’t use mysql • MySQL acquired by Sun • Sun
acquired by Oracle • Oracle makes a lot of money charging for databases
DO HIRE SOMEONE
hire someone • Percona.com MySQL Consulting & Services • PSCE.com
MySQL Consulting & Services
questions? jeff@pco.bz @TheBerg about.me/jeffberg ! slides at: https://speakerdeck.com/theberg