From 8ee52143fc2e93971e8127d9d3c1323808e42e27 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Tue, 29 Dec 2020 11:07:33 +0200 Subject: [PATCH] roles/mariadb: Disable the query cache by default It seems that the usefulness of the query cache is diminishing in recent years. If your cache is large then the time taken to scan the cache can be longer than the SQL query itself. See: https://haydenjames.io/mysql-query-cache-size-performance/ --- roles/mariadb/defaults/main.yml | 4 ++++ roles/mariadb/templates/my.cnf.j2 | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/mariadb/defaults/main.yml b/roles/mariadb/defaults/main.yml index f78bf02..15df54e 100644 --- a/roles/mariadb/defaults/main.yml +++ b/roles/mariadb/defaults/main.yml @@ -23,4 +23,8 @@ mariadb_login_unix_socket: /var/run/mysqld/mysqld.sock # default is 100 but the max I've seen used is 5, so let's reduce it max_connections: 33 +# disable the query cache by default +query_cache_size: 0 +query_cache_type: 0 + # vim: set ts=2 sw=2: diff --git a/roles/mariadb/templates/my.cnf.j2 b/roles/mariadb/templates/my.cnf.j2 index 40aa732..719bcfd 100644 --- a/roles/mariadb/templates/my.cnf.j2 +++ b/roles/mariadb/templates/my.cnf.j2 @@ -75,11 +75,9 @@ read_rnd_buffer_size = 1M # # * Query Cache Configuration # -# Cache only tiny result sets, so we can fit more in the query cache. query_cache_limit = 128K -query_cache_size = 64M -# for more write intensive setups, set to DEMAND or OFF -#query_cache_type = DEMAND +query_cache_size = {{ query_cache_size }} +query_cache_type = {{ query_cache_type }} # # * Logging and Replication #