2

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]>
4

1 に答える 1

0

これは、MariaDB 5.5.39 および 10.0.14 で確認できます。これが意図的な変更であったかどうかはわかりませんが (IMHO の MariaDB の動作の方がより正確です)、少なくとも MariaDB ナレッジ ベースのこのセクションによると、MySQL と同じように動作するはずです。

クエリ キャッシュから返されたクエリは Com_select ステータス変数をインクリメントしないことに注意してください。そのため、サーバー上で実行される有効なクエリの総数を確認するには、Com_select を Qcache_hits に追加します。

( https://mariadb.com/kb/en/mariadb/documentation/optimization-and-tuning/buffers-caches-and-threads/query-cache/ )

だから私はそれについてこのバグレポートを提出しました:

https://mariadb.atlassian.net/browse/MDEV-7216

于 2014-11-26T12:07:11.520 に答える