Handler_delete和Com_delete有什麼關係

Steven1981發表於2009-11-09
今天有人問, Handler_delete和Com_delete有什麼關係?
Handler_delete:
com_delete:[@more@]

這兩個都是MYSQL,SHOW STATUS裡的一個狀態變數.

根據MYSQL 5.0 官方文件解釋:
Handler_delete:
The number of times that rows have been deleted from tables.
DELETED行數.
com_delete:
The Com_xxx statement counter variables indicate the number of times each xxx statement has been executed.
DELETE命令的執行次數.

下面我們來測試一下:

(]> select * from t1;
+------+-------+
| name | n1 |
+------+-------+
| aaa | NULL |
| bbb | NULL |
| ccc | NULL |
| aaa | aaaaa |
+------+-------+
4 rows in set (0.00 sec)

(]> show global status like '%delete%';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Com_delete | 0 |
| Com_delete_multi | 0 |
| Handler_delete | 0 |
| Innodb_rows_deleted | 0 |
+---------------------+-------+
4 rows in set (0.00 sec)

(]> delete from t1;
Query OK, 4 rows affected (0.00 sec)

(]> commit;
Query OK, 0 rows affected (0.00 sec)

(]> show global status like '%delete%';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| Com_delete | 1 |
| Com_delete_multi | 0 |
| Handler_delete | 4 |
| Innodb_rows_deleted | 4 |
+---------------------+-------+
4 rows in set (0.00 sec)

從兩次SHOW STATUS的結果來看,官方文件的解釋是正確的!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/703656/viewspace-1028575/,如需轉載,請註明出處,否則將追究法律責任。

相關文章