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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
TheBerg
July 10, 2014
Technology
160
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DOs and DON'Ts of MySQL Performance
TheBerg
July 10, 2014
Other Decks in Technology
See All in Technology
SONiCで構築・運用する生成AI向けパブリッククラウドネットワーク ~実装編~
sonic
0
190
2026 TECHFRESH 畢業分享會 - 開發日常大解密!從領域驅動到企業級上線
line_developers_tw
PRO
0
960
Kubernetesにおける学習基盤とLLMOpsの概要
ry
1
290
失敗を経て、Harness Engineering で 大切にしたいことを考える / Learning from Failure: What Matters in Harness Engineering
bitkey
PRO
1
360
AIネイティブな開発のサプライチェーンリスク対策 〜激動の開発現場でリスクに立ち向かう〜【ZennFes】
cscengineer
PRO
2
120
【NRUG vol.18】なぜ多くのオブザーバビリティ導入は失敗するのか
nrug_member
0
120
On-behalf-of Token exchange with AgentCore Identity
hironobuiga
2
170
AIの性能が向上しても未解決な組織の重大問題は何か?/An Unsolved Organizational Problem in the Age of AI
moriyuya
4
660
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
1
200
あなたの AI ワークスペースに、 専門コーダーを連れてくる - Amazon Quick Desktop 最新情報
kawaji_scratch
1
130
日本 Fintech 未来予測レポート 2027〜2028年(手動編集版)
8maki
0
2.2k
FDE という解 ― 暗黙知と明示知をつなぐ、伴走型エンジニアリング ―
otanet
0
150
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.8k
Documentation Writing (for coders)
carmenintech
77
5.4k
Navigating Team Friction
lara
192
16k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
970
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Scaling GitHub
holman
464
140k
Deep Space Network (abreviated)
tonyrice
0
170
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.4k
Agile that works and the tools we love
rasmusluckow
331
21k
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