Question

MariaDB's QCache_hits and Com_select increase together.

For example.

MySQL

  • show global status - Com_select is 0. Qcache_hits is 0.
  • 1st select : select * from test_table where id = 1 - Com_select is 1. Qcache_hits is 0.
  • 2nd select : select * from test_table where id = 1 - Com_select is 1. Qcache_hits is 1.
  • 3rd select : select * from test_table where id = 1 - Com_select is 1. Qcache_hits is 2.

MariaDB

  • show global status - Com_select is 0. Qcache_hits is 0.
  • 1st select : select * from test_table where id = 1 - Com_select is 1. Qcache_hits is 0.
  • 2nd select : select * from test_table where id = 1 - Com_select is 2. Qcache_hits is 1.
  • 3rd select : select * from test_table where id = 1 - Com_select is 3. Qcache_hits is 2.

Why even when the number of Com_select increases if the cache is hit?

My environment is Ubunut 12.04(x64) and 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]>

No correct solution

OTHER TIPS

I can verify this with MariaDB 5.5.39 and 10.0.14. I'm not sure whether this was an intentional change (IMHO the MariaDB behavior is more correct), but at least according to this section in the MariaDB knowledge base it is supposed to behave the same way as MySQL here:

Note that queries returned from the query cache do not increment the Com_select status variable, so to find the total number of valid queries run on the server, add Com_select to Qcache_hits.

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

So I've filed this bug report about it:

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top