mysql簡要調優
##########################################################
benchmark()測試服務器速度
select benchmark(100000,10+10);
select benchmark(100000,extract(year from now()));
############################################################
key_buffer_size//用於索引的緩存大小,緩存越大,sql查詢就越快
show status
key_reads/key_read_requests<0.01
key_writes/key_write_requests<1
table_cache//全部線程所打開的表的數目。默認值64
若是open_table的數值越大,table_cache的值就應該增長
#############################################################
optimize table user; //ok表明優化過
+-------------+----------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-------------+----------+----------+----------+
| mytest.user | optimize | status | OK |
+-------------+----------+----------+----------+
mysql> optimize table user;//再次運行
+-------------+----------+----------+-----------------------------+
| Table | Op | Msg_type | Msg_text |
+-------------+----------+----------+-----------------------------+
| mytest.user | optimize | status | Table is already up to date |
+-------------+----------+----------+-----------------------------+
###############################################################
mysql> explain select * from user; //獲取select相關信息
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | user | ALL | NULL | NULL | NULL | NULL | 6 | |
+----+-------------+-------+------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)
#######################################
flush [privileges,tables,hosts,logs]
###########################################
性能瓶頸定位
set profiling=1;
select * from user;
show profiles;
show profiles type for query n type={all,block io,context switches,cpu,ipc,memory,page faults,source,swaps}