7.1 檢視sql的執行頻率
show 【session|global】 status;
實驗一:查詢自本次登陸以來的資料庫操作,主要關心值的獲取mysql> show session status like 'com_insert%';
+-------------------+-------+
| variable_name | value |
+-------------------+-------+
| com_insert | 0 |
| com_insert_select | 0 |
+-------------------+-------+
2 rows in set (0.00 sec)
mysql> show session status like 'com_select%';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| com_select | 43 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show session status like 'com_update%';
+------------------+-------+
| variable_name | value |
+------------------+-------+
| com_update | 0 |
| com_update_multi | 0 |
+------------------+-------+
2 rows in set (0.00 sec)
mysql> show session status like 'com_delete%';
+------------------+-------+
| variable_name | value |
+------------------+-------+
| com_delete | 4 |
| com_delete_multi | 0 |
+------------------+-------+
2 rows in set (0.00 sec)
實驗二:查詢自資料庫服務啟動以來的資料庫操作,主要關心值的獲取mysql> show global status like 'com_delete%';
+------------------+-------+
| variable_name | value |
+------------------+-------+
| com_delete | 7 |
| com_delete_multi | 0 |
+------------------+-------+
2 rows in set (0.00 sec)
mysql> show global status like 'com_insert%';
+-------------------+-------+
| variable_name | value |
+-------------------+-------+
| com_insert | 8 |
| com_insert_select | 7 |
+-------------------+-------+
2 rows in set (0.00 sec)
mysql> show global status like 'com_update%';
+------------------+-------+
| variable_name | value |
+------------------+-------+
| com_update | 0 |
| com_update_multi | 0 |
+------------------+-------+
2 rows in set (0.00 sec)
mysql> show global status like 'com_select%';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| com_select | 139 |
+---------------+-------+
1 row in set (0.00 sec)
實驗三:查詢自資料庫innodb引擎的資料庫操作,主要關心值的獲取的是影響的行數mysql> show session status like 'innodb_rows%';
+----------------------+-------+
| variable_name | value |
+----------------------+-------+
| innodb_rows_deleted | 2 |
| innodb_rows_inserted | 4 |
| innodb_rows_read | 27 |
| innodb_rows_updated | 0 |
+----------------------+-------+
4 rows in set (0.00 sec)
mysql> show global status like 'innodb_rows%';
+----------------------+-------+
| variable_name | value |
+----------------------+-------+
| innodb_rows_deleted | 2 |
| innodb_rows_inserted | 4 |
| innodb_rows_read | 27 |
| innodb_rows_updated | 0 |
+----------------------+-------+
4 rows in set (0.00 sec)
mysql> show global status like 'connections';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| connections | 8 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show session status like 'connections';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| connections | 8 |
+---------------+-------+
1 row in set (0.00 sec)
實驗五:檢視資料庫的工作的時間秒數mysql> show session status like 'uptime';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| uptime | 25002 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show global status like 'uptime';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| uptime | 25014 |
+---------------+-------+
1 row in set (0.00 sec)
實驗六:檢視資料庫的滿查詢的次數mysql> show global status like 'slow_queries';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| slow_queries | 0 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show session status like 'slow_queries';
+---------------+-------+
| variable_name | value |
+---------------+-------+
| slow_queries | 0 |
+---------------+-------+
1 row in set (0.00 sec)
限制sql檔案執行頻率
對於pxc,為了避免流控,可以在匯入.sql檔案時,先對檔案做處理 awk 1 nr 1000 0 sql dba.sql 上面的命令每1000行增加一行select sleep 1 這樣執行頻率是1k s 對於mysqldump產生的sql檔案,則需要在匯出時指定 mysqldump skip e...
MySQL優化 如何了解SQL的執行頻率
hacms開源社群 mysql 客戶端連線成功後,通過 show session global status 命令 可以提供伺服器狀態資訊,也可以在作業系統上使用 mysqladmin extended status 命令獲得這些訊息。show session global status 可以根據需...
MySQL優化 如何了解SQL的執行頻率
mysql 客戶端連線成功後,通過 show session global status 命令 可以提供伺服器狀態資訊,也可以在作業系統上使用 mysqladmin extended status 命令獲得這些訊息。show session global status 可以根據需要加上引數 sess...