MariaDB の QCache_hits と Com_select は一緒に増加します。
例えば。
MySQL
- グローバル ステータスを表示 - Com_select は 0 です。Qcache_hits は 0 です。
- 最初の select : select * from test_table where id = 1 - Com_select は 1 です。Qcache_hits は 0 です。
- 2 番目の select : select * from test_table where id = 1 - Com_select は 1 です。Qcache_hits は 1 です。
- 3 番目の select : select * from test_table where id = 1 - Com_select は 1 です。Qcache_hits は 2 です。
マリアDB
- グローバル ステータスを表示 - Com_select は 0 です。Qcache_hits は 0 です。
- 最初の select : select * from test_table where id = 1 - Com_select は 1 です。Qcache_hits は 0 です。
- 2 番目の select : select * from test_table where id = 1 - Com_select は 2 です。Qcache_hits は 1 です。
- 3 番目の select : select * from test_table where id = 1 - Com_select は 3 です。Qcache_hits は 2 です。
キャッシュにヒットすると Com_select の数が増えてもなぜですか?
私の環境は Ubunut 12.04(x64) と MariaDB 5.5.35 です。
MariaDB [test]> show global status where Variable_name in ('Com_select', 'Qcache_hits');
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select | 79 |
| Qcache_hits | 6 |
+---------------+-------+
2 rows in set (0.00 sec)
MariaDB [test]> insert into testtable values (11, 3);
Query OK, 1 row affected (0.00 sec)<br/>
MariaDB [test]> select * from testtable where id = 11;
+----+------+
| id | name |
+----+------+
| 11 | 3 |
+----+------+
1 row in set (0.00 sec)
MariaDB [test]> show global status where Variable_name in ('Com_select', 'Qcache_hits') ;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select | 80 |
| Qcache_hits | 6 |
+---------------+-------+
2 rows in set (0.00 sec)
MariaDB [test]> select * from testtable where id = 11;
+----+------+
| id | name |
+----+------+
| 11 | 3 |
+----+------+
1 row in set (0.00 sec)
MariaDB [test]> select * from testtable where id = 11;
+----+------+
| id | name |
+----+------+
| 11 | 3 |
+----+------+
1 row in set (0.00 sec)
MariaDB [test]> show global status where Variable_name in ('Com_select', 'Qcache_hits') ;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_select | 82 |
| Qcache_hits | 8 |
+---------------+-------+
2 rows in set (0.00 sec)
MariaDB [test]>