WEB开发网
开发学院数据库MySQL MySQL性能优化实战 阅读

MySQL性能优化实战

 2009-04-21 11:17:26 来源:WEB开发网   
核心提示: 然后发挥您的想象力在这个表中尽力捕捉你想捕捉的,那类型语句压力最大、扫描行数最多、等锁最久……比如:优化后:mysql>selectsum(query_time)/count(*),count(*),sum(query_time),min(Date),Ma

然后发挥您的想象力在这个表中尽力捕捉你想捕捉的,那类型语句压力最大、扫描行数最多、等锁最久……

比如:

优化后:

mysql> select sum(query_time)/count(*),count 
(*),sum(query_time),min(Date),Max(Date) from slow where Date>'2008-02-20 22:50:52'
and Date<'2008-02-21 17:34:35';
+--------------------------+----------+-----------------+---------------------+---------------------+
| sum(query_time)/count(*) | count(*) | sum(query_time) | min(Date)      | Max(Date)      |
+--------------------------+----------+-----------------+---------------------+---------------------+
|          5.7233 |   2197 |      12574 | 2008-02-20 22:51:16 | 2008-02-21 17:34:10 | 
+--------------------------+----------+-----------------+---------------------+---------------------+
1 row in set (0.09 sec)

优化前:

mysql> select sum(query_time)/count(*),count(*),sum(query_time),min(Date),Max(Date) from slow 
where Date>'2008-02-17 22:50:52' and Date<'2008-02-18 17:34:35';
+--------------------------+----------+-----------------+---------------------+---------------------+
| sum(query_time)/count(*) | count(*) | sum(query_time) | min(Date)      | Max(Date)      |
+--------------------------+----------+-----------------+---------------------+---------------------+
|          2.5983 |  16091 |      41810 | 2008-02-17 22:50:58 | 2008-02-18 17:34:34 | 
+--------------------------+----------+-----------------+---------------------+---------------------+
1 row in set (0.15 sec)

Tags:MySQL 性能 优化

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接