5.5 merge
This commit is contained in:
commit
3c12c27907
@ -0,0 +1,56 @@
|
|||||||
|
SET @start_global_value = @@global.innodb_stats_modified_counter;
|
||||||
|
SELECT @start_global_value;
|
||||||
|
@start_global_value
|
||||||
|
0
|
||||||
|
Valid values are one or above
|
||||||
|
select @@global.innodb_stats_modified_counter >=1;
|
||||||
|
@@global.innodb_stats_modified_counter >=1
|
||||||
|
0
|
||||||
|
select @@global.innodb_stats_modified_counter;
|
||||||
|
@@global.innodb_stats_modified_counter
|
||||||
|
0
|
||||||
|
select @@session.innodb_stats_modified_counter;
|
||||||
|
ERROR HY000: Variable 'innodb_stats_modified_counter' is a GLOBAL variable
|
||||||
|
show global variables like 'innodb_stats_modified_counter';
|
||||||
|
Variable_name Value
|
||||||
|
innodb_stats_modified_counter 0
|
||||||
|
show session variables like 'innodb_stats_modified_counter';
|
||||||
|
Variable_name Value
|
||||||
|
innodb_stats_modified_counter 0
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_MODIFIED_COUNTER 0
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_MODIFIED_COUNTER 0
|
||||||
|
set global innodb_stats_modified_counter=10;
|
||||||
|
select @@global.innodb_stats_modified_counter;
|
||||||
|
@@global.innodb_stats_modified_counter
|
||||||
|
10
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_MODIFIED_COUNTER 10
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_MODIFIED_COUNTER 10
|
||||||
|
set session innodb_stats_modified_counter=1;
|
||||||
|
ERROR HY000: Variable 'innodb_stats_modified_counter' is a GLOBAL variable and should be set with SET GLOBAL
|
||||||
|
set global innodb_stats_modified_counter=1.1;
|
||||||
|
ERROR 42000: Incorrect argument type to variable 'innodb_stats_modified_counter'
|
||||||
|
set global innodb_stats_modified_counter=1e1;
|
||||||
|
ERROR 42000: Incorrect argument type to variable 'innodb_stats_modified_counter'
|
||||||
|
set global innodb_stats_modified_counter="foo";
|
||||||
|
ERROR 42000: Incorrect argument type to variable 'innodb_stats_modified_counter'
|
||||||
|
set global innodb_stats_modified_counter=-7;
|
||||||
|
Warnings:
|
||||||
|
Warning 1292 Truncated incorrect innodb_stats_modified_counter value: '-7'
|
||||||
|
select @@global.innodb_stats_modified_counter;
|
||||||
|
@@global.innodb_stats_modified_counter
|
||||||
|
0
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_MODIFIED_COUNTER 0
|
||||||
|
SET @@global.innodb_stats_modified_counter = @start_global_value;
|
||||||
|
SELECT @@global.innodb_stats_modified_counter;
|
||||||
|
@@global.innodb_stats_modified_counter
|
||||||
|
0
|
@ -0,0 +1,92 @@
|
|||||||
|
SET @start_global_value = @@global.innodb_stats_traditional;
|
||||||
|
SELECT @start_global_value;
|
||||||
|
@start_global_value
|
||||||
|
0
|
||||||
|
Valid values are 'ON' and 'OFF'
|
||||||
|
select @@global.innodb_stats_traditional in (0, 1);
|
||||||
|
@@global.innodb_stats_traditional in (0, 1)
|
||||||
|
1
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
0
|
||||||
|
select @@session.innodb_stats_traditional;
|
||||||
|
ERROR HY000: Variable 'innodb_stats_traditional' is a GLOBAL variable
|
||||||
|
show global variables like 'innodb_stats_traditional';
|
||||||
|
Variable_name Value
|
||||||
|
innodb_stats_traditional OFF
|
||||||
|
show session variables like 'innodb_stats_traditional';
|
||||||
|
Variable_name Value
|
||||||
|
innodb_stats_traditional OFF
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL OFF
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL OFF
|
||||||
|
set global innodb_stats_traditional='OFF';
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
0
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL OFF
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL OFF
|
||||||
|
set @@global.innodb_stats_traditional=1;
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
1
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL ON
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL ON
|
||||||
|
set global innodb_stats_traditional=0;
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
0
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL OFF
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL OFF
|
||||||
|
set @@global.innodb_stats_traditional='ON';
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
1
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL ON
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL ON
|
||||||
|
set session innodb_stats_traditional='OFF';
|
||||||
|
ERROR HY000: Variable 'innodb_stats_traditional' is a GLOBAL variable and should be set with SET GLOBAL
|
||||||
|
set @@session.innodb_stats_traditional='ON';
|
||||||
|
ERROR HY000: Variable 'innodb_stats_traditional' is a GLOBAL variable and should be set with SET GLOBAL
|
||||||
|
set global innodb_stats_traditional=1.1;
|
||||||
|
ERROR 42000: Incorrect argument type to variable 'innodb_stats_traditional'
|
||||||
|
set global innodb_stats_traditional=1e1;
|
||||||
|
ERROR 42000: Incorrect argument type to variable 'innodb_stats_traditional'
|
||||||
|
set global innodb_stats_traditional=2;
|
||||||
|
ERROR 42000: Variable 'innodb_stats_traditional' can't be set to the value of '2'
|
||||||
|
set global innodb_stats_traditional=-3;
|
||||||
|
ERROR 42000: Variable 'innodb_stats_traditional' can't be set to the value of '-3'
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
1
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL ON
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
VARIABLE_NAME VARIABLE_VALUE
|
||||||
|
INNODB_STATS_TRADITIONAL ON
|
||||||
|
set global innodb_stats_traditional='AUTO';
|
||||||
|
ERROR 42000: Variable 'innodb_stats_traditional' can't be set to the value of 'AUTO'
|
||||||
|
SET @@global.innodb_stats_traditional = @start_global_value;
|
||||||
|
SELECT @@global.innodb_stats_traditional;
|
||||||
|
@@global.innodb_stats_traditional
|
||||||
|
0
|
@ -0,0 +1,47 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
SET @start_global_value = @@global.innodb_stats_modified_counter;
|
||||||
|
SELECT @start_global_value;
|
||||||
|
|
||||||
|
#
|
||||||
|
# exists as global only
|
||||||
|
#
|
||||||
|
--echo Valid values are one or above
|
||||||
|
select @@global.innodb_stats_modified_counter >=1;
|
||||||
|
select @@global.innodb_stats_modified_counter;
|
||||||
|
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||||
|
select @@session.innodb_stats_modified_counter;
|
||||||
|
show global variables like 'innodb_stats_modified_counter';
|
||||||
|
show session variables like 'innodb_stats_modified_counter';
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
|
||||||
|
#
|
||||||
|
# show that it's writable
|
||||||
|
#
|
||||||
|
set global innodb_stats_modified_counter=10;
|
||||||
|
select @@global.innodb_stats_modified_counter;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
--error ER_GLOBAL_VARIABLE
|
||||||
|
set session innodb_stats_modified_counter=1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# incorrect types
|
||||||
|
#
|
||||||
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
|
set global innodb_stats_modified_counter=1.1;
|
||||||
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
|
set global innodb_stats_modified_counter=1e1;
|
||||||
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
|
set global innodb_stats_modified_counter="foo";
|
||||||
|
|
||||||
|
set global innodb_stats_modified_counter=-7;
|
||||||
|
select @@global.innodb_stats_modified_counter;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_modified_counter';
|
||||||
|
|
||||||
|
#
|
||||||
|
# cleanup
|
||||||
|
#
|
||||||
|
SET @@global.innodb_stats_modified_counter = @start_global_value;
|
||||||
|
SELECT @@global.innodb_stats_modified_counter;
|
@ -0,0 +1,65 @@
|
|||||||
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
SET @start_global_value = @@global.innodb_stats_traditional;
|
||||||
|
SELECT @start_global_value;
|
||||||
|
|
||||||
|
#
|
||||||
|
# exists as global only
|
||||||
|
#
|
||||||
|
--echo Valid values are 'ON' and 'OFF'
|
||||||
|
select @@global.innodb_stats_traditional in (0, 1);
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
|
||||||
|
select @@session.innodb_stats_traditional;
|
||||||
|
show global variables like 'innodb_stats_traditional';
|
||||||
|
show session variables like 'innodb_stats_traditional';
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
|
||||||
|
#
|
||||||
|
# show that it's writable
|
||||||
|
#
|
||||||
|
set global innodb_stats_traditional='OFF';
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
set @@global.innodb_stats_traditional=1;
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
set global innodb_stats_traditional=0;
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
set @@global.innodb_stats_traditional='ON';
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
--error ER_GLOBAL_VARIABLE
|
||||||
|
set session innodb_stats_traditional='OFF';
|
||||||
|
--error ER_GLOBAL_VARIABLE
|
||||||
|
set @@session.innodb_stats_traditional='ON';
|
||||||
|
|
||||||
|
#
|
||||||
|
# incorrect types
|
||||||
|
#
|
||||||
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
|
set global innodb_stats_traditional=1.1;
|
||||||
|
--error ER_WRONG_TYPE_FOR_VAR
|
||||||
|
set global innodb_stats_traditional=1e1;
|
||||||
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
|
set global innodb_stats_traditional=2;
|
||||||
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
|
set global innodb_stats_traditional=-3;
|
||||||
|
select @@global.innodb_stats_traditional;
|
||||||
|
select * from information_schema.global_variables where variable_name='innodb_stats_traditional';
|
||||||
|
select * from information_schema.session_variables where variable_name='innodb_stats_traditional';
|
||||||
|
--error ER_WRONG_VALUE_FOR_VAR
|
||||||
|
set global innodb_stats_traditional='AUTO';
|
||||||
|
|
||||||
|
#
|
||||||
|
# Cleanup
|
||||||
|
#
|
||||||
|
|
||||||
|
SET @@global.innodb_stats_traditional = @start_global_value;
|
||||||
|
SELECT @@global.innodb_stats_traditional;
|
@ -3870,16 +3870,29 @@ btr_estimate_number_of_different_key_vals(
|
|||||||
ut_error;
|
ut_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It makes no sense to test more pages than are contained
|
if (srv_stats_sample_traditional) {
|
||||||
in the index, thus we lower the number if it is too high */
|
/* It makes no sense to test more pages than are contained
|
||||||
if (srv_stats_transient_sample_pages > index->stat_index_size) {
|
in the index, thus we lower the number if it is too high */
|
||||||
|
if (srv_stats_transient_sample_pages > index->stat_index_size) {
|
||||||
|
if (index->stat_index_size > 0) {
|
||||||
|
n_sample_pages = index->stat_index_size;
|
||||||
|
} else {
|
||||||
|
n_sample_pages = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
n_sample_pages = srv_stats_transient_sample_pages;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* New logaritmic number of pages that are estimated. We
|
||||||
|
first pick minimun from srv_stats_transient_sample_pages and number of
|
||||||
|
pages on index. Then we pick maximum from previous number of
|
||||||
|
pages and log2(number of index pages) * srv_stats_transient_sample_pages. */
|
||||||
if (index->stat_index_size > 0) {
|
if (index->stat_index_size > 0) {
|
||||||
n_sample_pages = index->stat_index_size;
|
n_sample_pages = ut_max(ut_min(srv_stats_transient_sample_pages, index->stat_index_size),
|
||||||
|
log2(index->stat_index_size)*srv_stats_transient_sample_pages);
|
||||||
} else {
|
} else {
|
||||||
n_sample_pages = 1;
|
n_sample_pages = 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
n_sample_pages = srv_stats_transient_sample_pages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We sample some pages in the index to get an estimate */
|
/* We sample some pages in the index to get an estimate */
|
||||||
|
@ -16364,6 +16364,16 @@ static MYSQL_SYSVAR_ULONGLONG(stats_persistent_sample_pages,
|
|||||||
"statistics (by ANALYZE, default 20)",
|
"statistics (by ANALYZE, default 20)",
|
||||||
NULL, NULL, 20, 1, ~0ULL, 0);
|
NULL, NULL, 20, 1, ~0ULL, 0);
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_ULONGLONG(stats_modified_counter, srv_stats_modified_counter,
|
||||||
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
"The number of rows modified before we calculate new statistics (default 0 = current limits)",
|
||||||
|
NULL, NULL, 0, 0, ~0ULL, 0);
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_BOOL(stats_traditional, srv_stats_sample_traditional,
|
||||||
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
"Enable traditional statistic calculation based on number of configured pages (default false)",
|
||||||
|
NULL, NULL, FALSE);
|
||||||
|
|
||||||
static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
|
static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
|
||||||
PLUGIN_VAR_OPCMDARG,
|
PLUGIN_VAR_OPCMDARG,
|
||||||
"Enable InnoDB adaptive hash index (enabled by default). "
|
"Enable InnoDB adaptive hash index (enabled by default). "
|
||||||
@ -16989,6 +16999,8 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
|
|||||||
MYSQL_SYSVAR(stats_persistent),
|
MYSQL_SYSVAR(stats_persistent),
|
||||||
MYSQL_SYSVAR(stats_persistent_sample_pages),
|
MYSQL_SYSVAR(stats_persistent_sample_pages),
|
||||||
MYSQL_SYSVAR(stats_auto_recalc),
|
MYSQL_SYSVAR(stats_auto_recalc),
|
||||||
|
MYSQL_SYSVAR(stats_modified_counter),
|
||||||
|
MYSQL_SYSVAR(stats_traditional),
|
||||||
MYSQL_SYSVAR(adaptive_hash_index),
|
MYSQL_SYSVAR(adaptive_hash_index),
|
||||||
MYSQL_SYSVAR(stats_method),
|
MYSQL_SYSVAR(stats_method),
|
||||||
MYSQL_SYSVAR(replication_delay),
|
MYSQL_SYSVAR(replication_delay),
|
||||||
|
@ -356,6 +356,8 @@ extern unsigned long long srv_stats_transient_sample_pages;
|
|||||||
extern my_bool srv_stats_persistent;
|
extern my_bool srv_stats_persistent;
|
||||||
extern unsigned long long srv_stats_persistent_sample_pages;
|
extern unsigned long long srv_stats_persistent_sample_pages;
|
||||||
extern my_bool srv_stats_auto_recalc;
|
extern my_bool srv_stats_auto_recalc;
|
||||||
|
extern unsigned long long srv_stats_modified_counter;
|
||||||
|
extern my_bool srv_stats_sample_traditional;
|
||||||
|
|
||||||
extern ibool srv_use_doublewrite_buf;
|
extern ibool srv_use_doublewrite_buf;
|
||||||
extern ulong srv_doublewrite_batch_size;
|
extern ulong srv_doublewrite_batch_size;
|
||||||
|
@ -1055,8 +1055,12 @@ row_update_statistics_if_needed(
|
|||||||
since the last time a statistics batch was run.
|
since the last time a statistics batch was run.
|
||||||
We calculate statistics at most every 16th round, since we may have
|
We calculate statistics at most every 16th round, since we may have
|
||||||
a counter table which is very small and updated very often. */
|
a counter table which is very small and updated very often. */
|
||||||
|
ib_uint64_t threshold= 16 + n_rows / 16; /* 6.25% */
|
||||||
|
if (srv_stats_modified_counter)
|
||||||
|
threshold= ut_min(srv_stats_modified_counter, threshold);
|
||||||
|
|
||||||
if (counter > 16 + n_rows / 16 /* 6.25% */) {
|
if (counter > threshold) {
|
||||||
|
ib_uint64_t threshold= 16 + n_rows / 16; /* 6.25% */
|
||||||
|
|
||||||
ut_ad(!mutex_own(&dict_sys->mutex));
|
ut_ad(!mutex_own(&dict_sys->mutex));
|
||||||
/* this will reset table->stat_modified_counter to 0 */
|
/* this will reset table->stat_modified_counter to 0 */
|
||||||
|
@ -340,6 +340,14 @@ UNIV_INTERN my_bool srv_stats_persistent = TRUE;
|
|||||||
UNIV_INTERN unsigned long long srv_stats_persistent_sample_pages = 20;
|
UNIV_INTERN unsigned long long srv_stats_persistent_sample_pages = 20;
|
||||||
UNIV_INTERN my_bool srv_stats_auto_recalc = TRUE;
|
UNIV_INTERN my_bool srv_stats_auto_recalc = TRUE;
|
||||||
|
|
||||||
|
/* The number of rows modified before we calculate new statistics (default 0
|
||||||
|
= current limits) */
|
||||||
|
UNIV_INTERN unsigned long long srv_stats_modified_counter = 0;
|
||||||
|
|
||||||
|
/* Enable traditional statistic calculation based on number of configured
|
||||||
|
pages default false. */
|
||||||
|
UNIV_INTERN my_bool srv_stats_sample_traditional = FALSE;
|
||||||
|
|
||||||
UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;
|
UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;
|
||||||
|
|
||||||
/** doublewrite buffer is 1MB is size i.e.: it can hold 128 16K pages.
|
/** doublewrite buffer is 1MB is size i.e.: it can hold 128 16K pages.
|
||||||
|
@ -4061,16 +4061,29 @@ btr_estimate_number_of_different_key_vals(
|
|||||||
ut_error;
|
ut_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It makes no sense to test more pages than are contained
|
if (srv_stats_sample_traditional) {
|
||||||
in the index, thus we lower the number if it is too high */
|
/* It makes no sense to test more pages than are contained
|
||||||
if (srv_stats_transient_sample_pages > index->stat_index_size) {
|
in the index, thus we lower the number if it is too high */
|
||||||
|
if (srv_stats_transient_sample_pages > index->stat_index_size) {
|
||||||
|
if (index->stat_index_size > 0) {
|
||||||
|
n_sample_pages = index->stat_index_size;
|
||||||
|
} else {
|
||||||
|
n_sample_pages = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
n_sample_pages = srv_stats_transient_sample_pages;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* New logaritmic number of pages that are estimated. We
|
||||||
|
first pick minimun from srv_stats_transient_sample_pages and number of
|
||||||
|
pages on index. Then we pick maximum from previous number of
|
||||||
|
pages and log2(number of index pages) * srv_stats_transient_sample_pages. */
|
||||||
if (index->stat_index_size > 0) {
|
if (index->stat_index_size > 0) {
|
||||||
n_sample_pages = index->stat_index_size;
|
n_sample_pages = ut_max(ut_min(srv_stats_transient_sample_pages, index->stat_index_size),
|
||||||
|
log2(index->stat_index_size)*srv_stats_transient_sample_pages);
|
||||||
} else {
|
} else {
|
||||||
n_sample_pages = 1;
|
n_sample_pages = 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
n_sample_pages = srv_stats_transient_sample_pages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We sample some pages in the index to get an estimate */
|
/* We sample some pages in the index to get an estimate */
|
||||||
|
@ -17462,6 +17462,16 @@ static MYSQL_SYSVAR_ULONGLONG(stats_persistent_sample_pages,
|
|||||||
"statistics (by ANALYZE, default 20)",
|
"statistics (by ANALYZE, default 20)",
|
||||||
NULL, NULL, 20, 1, ~0ULL, 0);
|
NULL, NULL, 20, 1, ~0ULL, 0);
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_ULONGLONG(stats_modified_counter, srv_stats_modified_counter,
|
||||||
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
"The number of rows modified before we calculate new statistics (default 0 = current limits)",
|
||||||
|
NULL, NULL, 0, 0, ~0ULL, 0);
|
||||||
|
|
||||||
|
static MYSQL_SYSVAR_BOOL(stats_traditional, srv_stats_sample_traditional,
|
||||||
|
PLUGIN_VAR_RQCMDARG,
|
||||||
|
"Enable traditional statistic calculation based on number of configured pages (default false)",
|
||||||
|
NULL, NULL, FALSE);
|
||||||
|
|
||||||
static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
|
static MYSQL_SYSVAR_BOOL(adaptive_hash_index, btr_search_enabled,
|
||||||
PLUGIN_VAR_OPCMDARG,
|
PLUGIN_VAR_OPCMDARG,
|
||||||
"Enable InnoDB adaptive hash index (enabled by default). "
|
"Enable InnoDB adaptive hash index (enabled by default). "
|
||||||
@ -18284,6 +18294,8 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
|
|||||||
MYSQL_SYSVAR(stats_persistent),
|
MYSQL_SYSVAR(stats_persistent),
|
||||||
MYSQL_SYSVAR(stats_persistent_sample_pages),
|
MYSQL_SYSVAR(stats_persistent_sample_pages),
|
||||||
MYSQL_SYSVAR(stats_auto_recalc),
|
MYSQL_SYSVAR(stats_auto_recalc),
|
||||||
|
MYSQL_SYSVAR(stats_modified_counter),
|
||||||
|
MYSQL_SYSVAR(stats_traditional),
|
||||||
MYSQL_SYSVAR(adaptive_hash_index),
|
MYSQL_SYSVAR(adaptive_hash_index),
|
||||||
MYSQL_SYSVAR(adaptive_hash_index_partitions),
|
MYSQL_SYSVAR(adaptive_hash_index_partitions),
|
||||||
MYSQL_SYSVAR(stats_method),
|
MYSQL_SYSVAR(stats_method),
|
||||||
|
@ -427,6 +427,8 @@ extern unsigned long long srv_stats_transient_sample_pages;
|
|||||||
extern my_bool srv_stats_persistent;
|
extern my_bool srv_stats_persistent;
|
||||||
extern unsigned long long srv_stats_persistent_sample_pages;
|
extern unsigned long long srv_stats_persistent_sample_pages;
|
||||||
extern my_bool srv_stats_auto_recalc;
|
extern my_bool srv_stats_auto_recalc;
|
||||||
|
extern unsigned long long srv_stats_modified_counter;
|
||||||
|
extern my_bool srv_stats_sample_traditional;
|
||||||
|
|
||||||
extern ibool srv_use_doublewrite_buf;
|
extern ibool srv_use_doublewrite_buf;
|
||||||
extern ulong srv_doublewrite_batch_size;
|
extern ulong srv_doublewrite_batch_size;
|
||||||
|
@ -1054,8 +1054,11 @@ row_update_statistics_if_needed(
|
|||||||
since the last time a statistics batch was run.
|
since the last time a statistics batch was run.
|
||||||
We calculate statistics at most every 16th round, since we may have
|
We calculate statistics at most every 16th round, since we may have
|
||||||
a counter table which is very small and updated very often. */
|
a counter table which is very small and updated very often. */
|
||||||
|
ib_uint64_t threshold= 16 + n_rows / 16; /* 6.25% */
|
||||||
|
if (srv_stats_modified_counter)
|
||||||
|
threshold= ut_min(srv_stats_modified_counter, threshold);
|
||||||
|
|
||||||
if (counter > 16 + n_rows / 16 /* 6.25% */) {
|
if (counter > threshold) {
|
||||||
|
|
||||||
ut_ad(!mutex_own(&dict_sys->mutex));
|
ut_ad(!mutex_own(&dict_sys->mutex));
|
||||||
/* this will reset table->stat_modified_counter to 0 */
|
/* this will reset table->stat_modified_counter to 0 */
|
||||||
|
@ -457,6 +457,14 @@ UNIV_INTERN my_bool srv_stats_persistent = TRUE;
|
|||||||
UNIV_INTERN unsigned long long srv_stats_persistent_sample_pages = 20;
|
UNIV_INTERN unsigned long long srv_stats_persistent_sample_pages = 20;
|
||||||
UNIV_INTERN my_bool srv_stats_auto_recalc = TRUE;
|
UNIV_INTERN my_bool srv_stats_auto_recalc = TRUE;
|
||||||
|
|
||||||
|
/* The number of rows modified before we calculate new statistics (default 0
|
||||||
|
= current limits) */
|
||||||
|
UNIV_INTERN unsigned long long srv_stats_modified_counter = 0;
|
||||||
|
|
||||||
|
/* Enable traditional statistic calculation based on number of configured
|
||||||
|
pages default false. */
|
||||||
|
UNIV_INTERN my_bool srv_stats_sample_traditional = FALSE;
|
||||||
|
|
||||||
UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;
|
UNIV_INTERN ibool srv_use_doublewrite_buf = TRUE;
|
||||||
UNIV_INTERN ibool srv_use_atomic_writes = FALSE;
|
UNIV_INTERN ibool srv_use_atomic_writes = FALSE;
|
||||||
#ifdef HAVE_POSIX_FALLOCATE
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user