MySQL Optimization

February 12, 2007 by hejian

Starting Question
What version of MySQL are you using?
Which operating system?
MySQL dedicated or shared servers?
How fast is your growth? Thansaction rates, Data volumn

Need to Know
Operation system basics: Memory usage, swapping

MySQL’s Defaults
Tuned for small and medium data sets
Uses very little memory even if available
Suitable for use in a shared environment
Assumes little about your hardware
Begins to slow as growth continues
Uses non-transactional table (MyISAM): mose people need (90%), very low overhead

Operating System Tuning Tools
mytop: a console-based tool for monitoring the threads and overall performance of a MySQL server.
top, ps, vmstat
iostat, sar
mrtg, rrdtool

mysqld –verbose –help
mysqladmin extended-status

Important MySQL startup options
Find the bottlenecks:
long_query_time=1
log_slow_queries=slow_query.log
log-queries-not-using-indexes

table_cache: if the value Opened_tables is too big, so need increase the table_cache.
key_cache: if the value of Key_reads/Key_read_requests is too big, so need to increase the key_cache.

back_log Change if you do a lot of new connections.
thread_cache_size Change if you do a lot of new connections.
key_buffer_size Pool for index pages; Can be made very big
bdb_cache_size Record and key cache used by BDB tables.
delay_key_write Set if you need to buffer all key writes
max_heap_table_size Used with GROUP BY
sort_buffer Used with ORDER BY and GROUP BY
myisam_sort_buffer_size Used with REPAIR TABLE
join_buffer_size When doing a join without keys

Leave a Reply

You must be logged in to post a comment.

Wordpress template made by HeJian