diff options
author | unknown <bell@sanja.is.com.ua> | 2003-03-02 21:39:03 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-03-02 21:39:03 +0200 |
commit | 98077b0ef66dfc3ef14e0487f23b1e1e46b84f37 (patch) | |
tree | ec81cf25e43bd59edb6884368afd018c075a766e /sql | |
parent | 16cdf759a14c34b87c8d1b6924e65e55a3765d4c (diff) | |
download | mariadb-git-98077b0ef66dfc3ef14e0487f23b1e1e46b84f37.tar.gz |
made variable query_cache_min_res_unit from QUERY_CACHE_MIN_RESULT_DATA_SIZE (SCRUM)
mysql-test/r/query_cache.result:
test of query_cache_min_res_unit
mysql-test/t/query_cache.test:
test of query_cache_min_res_unit
sql/mysql_priv.h:
made variable query_cache_min_res_unit from QUERY_CACHE_MIN_RESULT_DATA_SIZE
sql/mysqld.cc:
made variable query_cache_min_res_unit from QUERY_CACHE_MIN_RESULT_DATA_SIZE
sql/set_var.cc:
made variable query_cache_min_res_unit from QUERY_CACHE_MIN_RESULT_DATA_SIZE
sql/sql_cache.cc:
method for parameter changing
sql/sql_cache.h:
method for parameter changing
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysql_priv.h | 5 | ||||
-rw-r--r-- | sql/mysqld.cc | 11 | ||||
-rw-r--r-- | sql/set_var.cc | 16 | ||||
-rw-r--r-- | sql/sql_cache.cc | 8 | ||||
-rw-r--r-- | sql/sql_cache.h | 3 |
5 files changed, 40 insertions, 3 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5bf7e6e6951..98a0f49cf82 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -307,6 +307,7 @@ typedef compare_func_creator (*chooser_compare_func_creator)(bool invert); #define query_cache_destroy() query_cache.destroy() #define query_cache_result_size_limit(A) query_cache.result_size_limit(A) #define query_cache_resize(A) query_cache.resize(A) +#define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A) #define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C) #define query_cache_invalidate1(A) query_cache.invalidate(A) #define query_cache_send_result_to_client(A, B, C) \ @@ -318,6 +319,7 @@ typedef compare_func_creator (*chooser_compare_func_creator)(bool invert); #define query_cache_destroy() #define query_cache_result_size_limit(A) #define query_cache_resize(A) +#define query_cache_set_min_res_unit(A) #define query_cache_invalidate3(A, B, C) #define query_cache_invalidate1(A) #define query_cache_send_result_to_client(A, B, C) 0 @@ -699,7 +701,8 @@ extern ulong filesort_rows, filesort_range_count, filesort_scan_count; extern ulong filesort_merge_passes; extern ulong select_range_check_count, select_range_count, select_scan_count; extern ulong select_full_range_join_count,select_full_join_count; -extern ulong slave_open_temp_tables, query_cache_size; +extern ulong slave_open_temp_tables; +extern ulong query_cache_size, query_cache_min_res_unit; extern ulong thd_startup_options, slow_launch_threads, slow_launch_time; extern ulong server_id, concurrency; extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ce87a8c15ac..8a815e6b965 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -363,7 +363,8 @@ ulong slave_net_timeout; ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0; ulong query_cache_size=0; #ifdef HAVE_QUERY_CACHE -ulong query_cache_limit=0; +ulong query_cache_limit= 0; +ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE; Query_cache query_cache; #endif arg_cmp_func Arg_comparator::comparator_matrix[4][2] = @@ -2148,6 +2149,7 @@ static int init_server_components() table_cache_init(); hostname_cache_init(); query_cache_result_size_limit(query_cache_limit); + query_cache_set_min_res_unit(query_cache_min_res_unit); query_cache_resize(query_cache_size); randominit(&sql_rand,(ulong) start_time,(ulong) start_time/2); reset_floating_point_exceptions(); @@ -3443,7 +3445,7 @@ enum options OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT, OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT, OPT_OPEN_FILES_LIMIT, - OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_SIZE, + OPT_QUERY_CACHE_LIMIT, OPT_QUERY_CACHE_MIN_RES_UNIT, OPT_QUERY_CACHE_SIZE, OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER, OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT, OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME, @@ -4206,6 +4208,11 @@ struct my_option my_long_options[] = "Don't cache results that are bigger than this.", (gptr*) &query_cache_limit, (gptr*) &query_cache_limit, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L, 0, (longlong) ULONG_MAX, 0, 1, 0}, + {"query_cache_min_res_unit", OPT_QUERY_CACHE_MIN_RES_UNIT, + "minimal size of unit in wich space for results is allocated (last unit will be trimed after writing all result data.", + (gptr*) &query_cache_min_res_unit, (gptr*) &query_cache_min_res_unit, + 0, GET_ULONG, REQUIRED_ARG, QUERY_CACHE_MIN_RESULT_DATA_SIZE, + 0, (longlong) ULONG_MAX, 0, 1, 0}, #endif /*HAVE_QUERY_CACHE*/ {"query_cache_size", OPT_QUERY_CACHE_SIZE, "The memory allocated to store results from old queries.", diff --git a/sql/set_var.cc b/sql/set_var.cc index 1f31633980a..509f79cfa91 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -85,6 +85,7 @@ static void fix_net_write_timeout(THD *thd, enum_var_type type); static void fix_net_retry_count(THD *thd, enum_var_type type); static void fix_max_join_size(THD *thd, enum_var_type type); static void fix_query_cache_size(THD *thd, enum_var_type type); +static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type); static void fix_key_buffer_size(THD *thd, enum_var_type type); static byte *get_error_count(THD *thd); static byte *get_warning_count(THD *thd); @@ -204,6 +205,9 @@ sys_var_long_ptr sys_query_cache_size("query_cache_size", #ifdef HAVE_QUERY_CACHE sys_var_long_ptr sys_query_cache_limit("query_cache_limit", &query_cache.query_cache_limit); +sys_var_long_ptr sys_query_cache_min_res_unit("query_cache_min_res_unit", + &query_cache_min_res_unit, + fix_query_cache_min_res_unit); sys_var_thd_enum sys_query_cache_type("query_cache_type", &SV::query_cache_type, &query_cache_type_typelib); @@ -384,6 +388,7 @@ sys_var *sys_variables[]= &sys_query_cache_size, #ifdef HAVE_QUERY_CACHE &sys_query_cache_limit, + &sys_query_cache_min_res_unit, &sys_query_cache_type, #endif /* HAVE_QUERY_CACHE */ &sys_quote_show_create, @@ -546,6 +551,8 @@ struct show_var_st init_vars[]= { {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS}, #ifdef HAVE_QUERY_CACHE {sys_query_cache_limit.name,(char*) &sys_query_cache_limit, SHOW_SYS}, + {sys_query_cache_min_res_unit.name, (char*) &sys_query_cache_min_res_unit, + SHOW_SYS}, {sys_query_cache_size.name, (char*) &sys_query_cache_size, SHOW_SYS}, {sys_query_cache_type.name, (char*) &sys_query_cache_type, SHOW_SYS}, #endif /* HAVE_QUERY_CACHE */ @@ -696,6 +703,15 @@ static void fix_query_cache_size(THD *thd, enum_var_type type) } +#ifdef HAVE_QUERY_CACHE +static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type) +{ + query_cache_min_res_unit= + query_cache.set_min_res_unit(query_cache_min_res_unit); +} +#endif + + static void fix_key_buffer_size(THD *thd, enum_var_type type) { ha_resize_key_cache(); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 90fd61ebeb7..7ea50a62239 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -743,6 +743,14 @@ ulong Query_cache::resize(ulong query_cache_size_arg) } +ulong Query_cache::set_min_res_unit(ulong size) +{ + if (size < min_allocation_unit) + size= min_allocation_unit; + return (min_result_data_size= ALIGN_SIZE(size)); +} + + void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) { TABLE_COUNTER_TYPE local_tables; diff --git a/sql/sql_cache.h b/sql/sql_cache.h index b15df28f54b..68bd3d48ff5 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -345,7 +345,10 @@ protected: /* resize query cache (return real query size, 0 if disabled) */ ulong resize(ulong query_cache_size); + /* set limit on result size */ inline void result_size_limit(ulong limit){query_cache_limit=limit;} + /* set minimal result data allocation unit size */ + ulong set_min_res_unit(ulong size); /* register query in cache */ void store_query(THD *thd, TABLE_LIST *used_tables); |