HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

MariaDB not caching any queries

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
anycachingqueriesnotmariadb

Problem

I tested several simple queries like such:

SELECT COUNT(*) FROM Users WHERE courses='a';


But none are being cached. The following are the cache related variables:

show variables like "%cache%";
+-------------------------------+----------------------+
| Variable_name                 | Value                |
+-------------------------------+----------------------+
| aria_pagecache_age_threshold  | 300                  |
| aria_pagecache_buffer_size    | 100000000            |
| aria_pagecache_division_limit | 100                  |
| binlog_cache_size             | 32768                |
| binlog_stmt_cache_size        | 32768                |
| have_query_cache              | YES                  |
| join_cache_level              | 2                    |
| key_cache_age_threshold       | 300                  |
| key_cache_block_size          | 1024                 |
| key_cache_division_limit      | 100                  |
| key_cache_segments            | 0                    |
| max_binlog_cache_size         | 18000000000000000000 |
| max_binlog_stmt_cache_size    | 18000000000000000000 |
| metadata_locks_cache_size     | 1024                 |
| query_cache_limit             | 1048576              |
| query_cache_min_res_unit      | 4096                 |
| query_cache_size              | 0                    |
| query_cache_strip_comments    | OFF                  |
| query_cache_type              | ON                   |
| query_cache_wlock_invalidate  | OFF                  |
| stored_program_cache          | 256                  |
| table_definition_cache        | 400                  |
| table_open_cache              | 400                  |
| thread_cache_size             | 0                    |
+-------------------------------+----------------------+


The cache related status shows:

```
show status like "%cache%";
+-----------------------------------+-------+
| Variable_name | Value |
+--------------------------------

Solution

You missed one thing.

query_cache_size              | 0



To set the size of the query cache, set the query_cache_size system variable. Setting it to 0 disables the query cache, as does setting query_cache_type=0.


https://dev.mysql.com/doc/refman/5.6/en/query-cache-configuration.html


Although enabled, the query cache size is by default 0KB, which effectively disables the query cache. Enable it by setting to an amount > 40KB


https://mariadb.com/kb/en/query-cache/

https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_query_cache_size

Code Snippets

query_cache_size              | 0

Context

StackExchange Database Administrators Q#59988, answer score: 5

Revisions (0)

No revisions yet.