标签:
mysql> show global status like ‘Threads_connected‘; //两次 mysql -uroot -p +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | Threads_connected | 2 | +-------------------+-------+ 1 row in set (0.01 sec) mysql> show global status like ‘Threads_running‘; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | Threads_running | 1 | +-----------------+-------+ 1 row in set (0.00 sec)
mysql> show processlist; +----+------+-----------+-------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+-------+---------+------+-------+------------------+ | 2 | root | localhost | mysql | Sleep | 4 | | NULL | | 3 | root | localhost | test | Query | 0 | init | show processlist | +----+------+-----------+-------+---------+------+-------+------------------+ 2 rows in set (0.00 sec)
mysql> create table ttt (a int); Query OK, 0 rows affected (0.22 sec) mysql> show global status like ‘Table_open_cache_hits‘; +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | Table_open_cache_hits | 31 | +-----------------------+-------+ 1 row in set (0.00 sec) mysql> show global status like ‘Table_open_cache_misses‘; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Table_open_cache_misses | 116 | +-------------------------+-------+ 1 row in set (0.00 sec) mysql> show global status like ‘Opened_tables‘; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Opened_tables | 116 | +---------------+-------+ 1 row in set (0.00 sec) mysql> select * from ttt; //第一次打开 Empty set (0.01 sec) mysql> show global status like ‘Opened_tables‘; //+1 +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Opened_tables | 117 | +---------------+-------+ 1 row in set (0.02 sec) mysql> show global status like ‘Table_open_cache_misses‘; //table缓存中没有表,丢失 +1 +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Table_open_cache_misses | 117 | +-------------------------+-------+ 1 row in set (0.01 sec) mysql> show global status like ‘Table_open_cache_hits‘; //缓存未命中,不变 +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | Table_open_cache_hits | 31 | +-----------------------+-------+ 1 row in set (0.01 sec) mysql> select * from ttt; //在打开表 Empty set (0.00 sec) mysql> show global status like ‘Table_open_cache_hits‘; //表缓存命中 +-----------------------+-------+ | Variable_name | Value | +-----------------------+-------+ | Table_open_cache_hits | 32 | +-----------------------+-------+ 1 row in set (0.01 sec)
MySQL的优化点总结---通过计算多种状态的百分比看MySQL的性能情况
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5608096.html