mysql> show global status like '%innodb%lock%';
+-------------------------------+-------+
| Variable_name | Value |
+-------------------------------+-------+
| Innodb_row_lock_current_waits | 0 |
| Innodb_row_lock_time | 51185 |
| Innodb_row_lock_time_avg | 5118 |
| Innodb_row_lock_time_max | 51003 |
| Innodb_row_lock_waits | 10 |
+-------------------------------+-------+测试
-- 两个事务更新同一行
-- 事务1
mysql> begin;
Query OK, 0 rows affected (0.00 sec)
mysql> update test set i=2 where i=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
-- 事务2
mysql> update test set i=3 where i=1;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
-- Innodb_row_lock_waits:10----->11mysql> show global status like '%Select_scan%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Select_scan | 210 |
+---------------+-------+mysql> show global status like '%tmp%';
+-------------------------+---------+
| Variable_name | Value |
+-------------------------+---------+
| Created_tmp_disk_tables | 11 |
| Created_tmp_files | 56 |
| Created_tmp_tables | 6047222 |
+-------------------------+---------+mysql> show global status like '%sort%';
+-------------------+------------+
| Variable_name | Value |
+-------------------+------------+
| Sort_merge_passes | 0 |
| Sort_range | 6047097 |
| Sort_rows | 1209407450 |
| Sort_scan | 6047093 |
+-------------------+------------+Sort_merge_passes值就是记录了使用文件进行排序的次数。由于文件排序要牵涉到读文件,打开文件句柄,然后关闭文件等操作。所以读取文件的系统消耗比较大,通过增大普通排序缓存sort_buffer_size来减少使用临时文件排序的次数,从而增加排序的性能。mysql> show global status like '%requests%';
+-----------------------------------+------------+
| Variable_name | Value |
+-----------------------------------+------------+
| Innodb_buffer_pool_read_requests | 3595145635 |
| Innodb_buffer_pool_write_requests | 956047096 |
+-----------------------------------+------------+
mysql> show global status like '%Innodb_buffer_pool_reads%';
+--------------------------+-----------+
| Variable_name | Value |
+--------------------------+-----------+
| Innodb_buffer_pool_reads | 184421999 |
+--------------------------+-----------+read命中率:
(Innodb_buffer_pool_read_requests - Innodb_buffer_pool_reads) /
Innodb_buffer_pool_read_requests * 100%mysql> show global status like '%Innodb_buffer_pool_pages_flushed%';
+----------------------------------+----------+
| Variable_name | Value |
+----------------------------------+----------+
| Innodb_buffer_pool_pages_flushed | 53761915 |
+----------------------------------+----------+
mysql> show global status like '%data_read%';
+-------------------+---------------+
| Variable_name | Value |
+-------------------+---------------+
| Innodb_data_read | 3202270515712 |
| Innodb_data_reads | 195483982 |
+-------------------+---------------+
mysql> show global status like '%data_writ%';
+---------------------+---------------+
| Variable_name | Value |
+---------------------+---------------+
| Innodb_data_writes | 94264653 |
| Innodb_data_written | 2399803565056 |
+---------------------+---------------+mysql> show global status like '%fsync%';
+------------------------------+----------+
| Variable_name | Value |
+------------------------------+----------+
| Innodb_data_fsyncs | 40679926 |
| Innodb_os_log_fsyncs | 4656424 |
+------------------------------+----------+odirect的数据直接写需要fsync刷inode cache和directory cache,日志用vfs缓冲区需要fsync刷一切
mysql> show global status like '%innodb_log%';
+---------------------------+-----------+
| Variable_name | Value |
+---------------------------+-----------+
| Innodb_log_write_requests | 152140181 |
| Innodb_log_writes | 4615988 |
+---------------------------+-----------+
mysql> show global status like '%Innodb_os_log_written%';
+-----------------------+-------------+
| Variable_name | Value |
+-----------------------+-------------+
| Innodb_os_log_written | 68112805376 |
+-----------------------+-------------+