diff --git a/dbcon/mysql/ha_mcs.cpp b/dbcon/mysql/ha_mcs.cpp index 598eb51af..5d9c2fbf8 100644 --- a/dbcon/mysql/ha_mcs.cpp +++ b/dbcon/mysql/ha_mcs.cpp @@ -32,7 +32,6 @@ #endif #define CACHE_PREFIX "#cache#" -#define CACHE_FLUSH_THRESHOLD 1000000 handlerton* mcs_hton = NULL; // This is the maria handlerton that we need for the cache @@ -1205,7 +1204,7 @@ my_bool get_status_and_flush_cache(void *param, { ha_rows num_rows = cache->num_rows_cached(); if ((!cache->insert_command && num_rows != 0) || - num_rows >= CACHE_FLUSH_THRESHOLD) + num_rows >= get_cache_flush_threshold(current_thd)) { if ((error= cache->flush_insert_cache())) { diff --git a/dbcon/mysql/ha_mcs_sysvars.cpp b/dbcon/mysql/ha_mcs_sysvars.cpp index 9d57fce51..eb1c1c531 100644 --- a/dbcon/mysql/ha_mcs_sysvars.cpp +++ b/dbcon/mysql/ha_mcs_sysvars.cpp @@ -312,6 +312,18 @@ static MYSQL_THDVAR_BOOL( 0 ); +static MYSQL_THDVAR_ULONGLONG( + cache_flush_threshold, + PLUGIN_VAR_RQCMDARG, + "Threshold on the number of rows in the cache to trigger a flush", + NULL, + NULL, + 500000, + 1, + 1000000000, + 1 +); + st_mysql_sys_var* mcs_system_variables[] = { MYSQL_SYSVAR(compression_type), @@ -338,6 +350,7 @@ st_mysql_sys_var* mcs_system_variables[] = MYSQL_SYSVAR(varbin_always_hex), MYSQL_SYSVAR(replication_slave), MYSQL_SYSVAR(cache_inserts), + MYSQL_SYSVAR(cache_flush_threshold), NULL }; @@ -578,3 +591,13 @@ void set_cache_inserts(THD* thd, bool value) { THDVAR(thd, cache_inserts) = value; } + +ulonglong get_cache_flush_threshold(THD* thd) +{ + return ( thd == NULL ) ? 500000 : THDVAR(thd, cache_flush_threshold); +} + +void set_cache_flush_threshold(THD* thd, ulonglong value) +{ + THDVAR(thd, cache_flush_threshold) = value; +} diff --git a/dbcon/mysql/ha_mcs_sysvars.h b/dbcon/mysql/ha_mcs_sysvars.h index 105660e79..ffb9f2fae 100644 --- a/dbcon/mysql/ha_mcs_sysvars.h +++ b/dbcon/mysql/ha_mcs_sysvars.h @@ -116,4 +116,7 @@ void set_replication_slave(THD* thd, bool value); bool get_cache_inserts(THD* thd); void set_cache_inserts(THD* thd, bool value); +ulonglong get_cache_flush_threshold(THD* thd); +void set_cache_flush_threshold(THD* thd, ulonglong value); + #endif