How to configure MySQL for performance
· Category: SQL & Databases
Short answer
Optimize MySQL performance by sizing the buffer pool, tuning connection limits, enabling query caching where appropriate, and using fast storage.
Steps
- Set
innodb_buffer_pool_sizeto 70-80% of available RAM for InnoDB-dedicated servers. - Tune
max_connectionsto match your application pool size. - Enable the slow query log and
long_query_timeto find bottlenecks. - Use SSD storage and separate data, log, and temp directories if possible.
- Optimize table structures and indexes based on
EXPLAINoutput.
Tips
- Monitor
Innodb_buffer_pool_read_requestsversusInnodb_buffer_pool_readsto measure cache hit ratio. - Use
pt-query-digestfrom Percona Toolkit to analyze slow query logs.
Common issues
- Setting
innodb_buffer_pool_sizetoo high causes OS swapping and severe performance degradation. - Table bloat from frequent updates benefits from
OPTIMIZE TABLEor dump-and-reload.r