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
DOs and DON'Ts of MySQL Performance
TheBerg
July 10, 2014
Other Decks in Technology
See All in Technology
ハーネスエンジニアリングの概要と設計思想
sergicalsix
9
3.8k
Do Ruby::Box dream of Modular Monolith?
joker1007
1
280
レビューしきれない?それは「全て人力でのレビュー」だからではないでしょうか
amixedcolor
0
250
Azure Static Web Apps の自動ビルドがタイムアウトしやすくなった状況に対応した件/global-azure2026
thara0402
0
350
扱える不確実性を増やしていく - スタートアップEMが考える「任せ方」
kadoppe
0
220
Azure PortalなどにみるWebアクセシビリティ
tomokusaba
0
370
CloudSec JP #005 後締め ~ソフトウェアサプライチェーン攻撃から開発者のシークレットを守る~
lhazy
0
220
2026年、知っておくべき最新 サーバレスTips10選/serverless-10-tips
slsops
13
5k
AIエージェントの権限管理 1: MCPサーバー・ツールの Fine grained access control 編
ren8k
3
480
Amazon S3 Filesについて
yama3133
2
170
AI時代における技術的負債への取り組み
codenote
0
1k
[OpsJAWS 40]リリースしたら終わり、じゃなかった。セキュリティ空白期間をAWS Security Agentで埋める
sh_fk2
3
200
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
240
Git: the NoSQL Database
bkeepers
PRO
432
67k
How to Talk to Developers About Accessibility
jct
2
170
For a Future-Friendly Web
brad_frost
183
10k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.1k
Technical Leadership for Architectural Decision Making
baasie
3
320
Agile that works and the tools we love
rasmusluckow
331
21k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Automating Front-end Workflow
addyosmani
1370
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