Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
MLflowダイエット大作戦
lycorptech_jp
PRO
1
160
半年で、AIゼロ知識から AI中心開発組織の変革担当に至るまで
rfdnxbro
0
120
Agent Skillsがハーネスの垣根を超える日
gotalab555
5
2.9k
業務のトイルをバスターせよ 〜AI時代の生存戦略〜
staka121
PRO
2
240
ExpoのインダストリーブースでみたAWSが見せる製造業の未来
hamadakoji
0
180
ペアーズにおけるAIエージェント 基盤とText to SQLツールの紹介
hisamouna
2
1.3k
Oracle Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
2
170
Amazon Quick Suite で始める手軽な AI エージェント
shimy
1
1.5k
AWS re:Invent 2025~初参加の成果と学び~
kubomasataka
0
170
re:Invent2025 3つの Frontier Agents を紹介 / introducing-3-frontier-agents
tomoki10
0
350
高度サイバー人材育成専科資料(前半)
nomizone
0
390
AIの長期記憶と短期記憶の違いについてAgentCoreを例に深掘ってみた
yakumo
4
470
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
25
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
120
The Language of Interfaces
destraynor
162
25k
Applied NLP in the Age of Generative AI
inesmontani
PRO
3
1.9k
WCS-LA-2024
lcolladotor
0
380
エンジニアに許された特別な時間の終わり
watany
105
220k
The browser strikes back
jonoalderson
0
67
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
0
98
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Exploring anti-patterns in Rails
aemeredith
2
200
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