From 3602e293a28a02a31aed0e30815db752c932f2f4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Mar 2007 10:36:15 -0700 Subject: [PATCH] Bug #26598: Create variable to allow turning off of statistic gathering on metadata commands Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). sql/mysqld.cc: Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). sql/set_var.cc: Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). storage/innobase/handler/ha_innodb.cc: Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). storage/innobase/handler/ha_innodb.h: Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). storage/innobase/include/srv0srv.h: Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). storage/innobase/srv/srv0srv.c: Add innodb_stats_on_metadata option, which enables gathering index statistics when processing metadata commands such as SHOW TABLE STATUS. Default behavior of the server does not change (this option is enabled by default). --- sql/mysqld.cc | 9 ++++++++- sql/set_var.cc | 4 +++- storage/innobase/handler/ha_innodb.cc | 17 +++++++++++------ storage/innobase/handler/ha_innodb.h | 3 ++- storage/innobase/include/srv0srv.h | 2 ++ storage/innobase/srv/srv0srv.c | 2 ++ 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2effbaac8e8..11d5da57792 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -399,6 +399,7 @@ extern my_bool innobase_log_archive, innobase_use_native_aio, innobase_file_per_table, innobase_locks_unsafe_for_binlog, innobase_rollback_on_timeout, + innobase_stats_on_metadata, innobase_create_status_file; extern "C" { extern ulong srv_max_buf_pool_modified_pct; @@ -4966,6 +4967,7 @@ enum options_mysqld OPT_INNODB_SYNC_SPIN_LOOPS, OPT_INNODB_CONCURRENCY_TICKETS, OPT_INNODB_THREAD_SLEEP_DELAY, + OPT_INNODB_STATS_ON_METADATA, OPT_BDB_CACHE_SIZE, OPT_BDB_CACHE_PARTS, OPT_BDB_LOG_BUFFER_SIZE, @@ -5311,6 +5313,10 @@ Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite, "Enable SHOW INNODB STATUS output in the innodb_status. file", (gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"innodb_stats_on_metadata", OPT_INNODB_STATS_ON_METADATA, + "Enable statistics gathering for metadata commands such as SHOW TABLE STATUS (on by default)", + (gptr*) &innobase_stats_on_metadata, (gptr*) &innobase_stats_on_metadata, + 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"innodb_support_xa", OPT_INNODB_SUPPORT_XA, "Enable InnoDB support for the XA two-phase commit", (gptr*) &global_system_variables.innodb_support_xa, @@ -8348,7 +8354,8 @@ my_bool innobase_log_archive, innobase_use_checksums, innobase_file_per_table, innobase_locks_unsafe_for_binlog, - innobase_rollback_on_timeout; + innobase_rollback_on_timeout, + innobase_stats_on_metadata; extern "C" { ulong srv_max_buf_pool_modified_pct; diff --git a/sql/set_var.cc b/sql/set_var.cc index 732f37a64f0..32568874d92 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -78,7 +78,8 @@ extern my_bool innobase_log_archive, innobase_use_checksums, innobase_file_per_table, innobase_locks_unsafe_for_binlog, - innobase_rollback_on_timeout; + innobase_rollback_on_timeout, + innobase_stats_on_metadata; extern "C" { extern ulong srv_max_buf_pool_modified_pct; @@ -835,6 +836,7 @@ SHOW_VAR init_vars[]= { {"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG}, {"innodb_open_files", (char*) &innobase_open_files, SHOW_LONG }, {"innodb_rollback_on_timeout", (char*) &innobase_rollback_on_timeout, SHOW_MY_BOOL}, + {"innodb_stats_on_metadata", (char*) &innobase_stats_on_metadata, SHOW_MY_BOOL}, {sys_innodb_support_xa.name, (char*) &sys_innodb_support_xa, SHOW_SYS}, {sys_innodb_sync_spin_loops.name, (char*) &sys_innodb_sync_spin_loops, SHOW_SYS}, {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS}, diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 14e93cca66f..e9309f4f8b8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -179,6 +179,7 @@ my_bool innobase_file_per_table = FALSE; my_bool innobase_locks_unsafe_for_binlog = FALSE; my_bool innobase_rollback_on_timeout = FALSE; my_bool innobase_create_status_file = FALSE; +my_bool innobase_stats_on_metadata = TRUE; static char *internal_innobase_data_file_path = NULL; @@ -1564,6 +1565,8 @@ innobase_init(void *p) srv_max_n_open_files = (ulint) innobase_open_files; srv_innodb_status = (ibool) innobase_create_status_file; + srv_stats_on_metadata = (ibool) innobase_stats_on_metadata; + srv_print_verbose_log = mysqld_embedded ? 0 : 1; /* Store the default charset-collation number of this MySQL @@ -5522,15 +5525,17 @@ ha_innobase::info( ib_table = prebuilt->table; if (flag & HA_STATUS_TIME) { - /* In sql_show we call with this flag: update then statistics - so that they are up-to-date */ + if (srv_stats_on_metadata) { + /* In sql_show we call with this flag: update then statistics + so that they are up-to-date */ - prebuilt->trx->op_info = (char*)"updating table statistics"; + prebuilt->trx->op_info = (char*)"updating table statistics"; - dict_update_statistics(ib_table); + dict_update_statistics(ib_table); - prebuilt->trx->op_info = (char*) - "returning various info to MySQL"; + prebuilt->trx->op_info = (char*) + "returning various info to MySQL"; + } my_snprintf(path, sizeof(path), "%s/%s%s", mysql_data_home, ib_table->name, reg_ext); diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index bc19f6fbf93..339238a584e 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -224,7 +224,8 @@ extern my_bool innobase_log_archive, innobase_use_native_aio, innobase_file_per_table, innobase_locks_unsafe_for_binlog, innobase_rollback_on_timeout, - innobase_create_status_file; + innobase_create_status_file, + innobase_stats_on_metadata; extern "C" { extern ulong srv_max_buf_pool_modified_pct; extern ulong srv_max_purge_lag; diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 9b617841f4c..1ad695f700c 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -124,6 +124,8 @@ extern ulint srv_fast_shutdown; /* If this is 1, do not do a transactions). */ extern ibool srv_innodb_status; +extern ibool srv_stats_on_metadata; + extern ibool srv_use_doublewrite_buf; extern ibool srv_use_checksums; diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 5d92b913934..2a177ed26cd 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -317,6 +317,8 @@ ulint srv_fast_shutdown = 0; /* Generate a innodb_status. file */ ibool srv_innodb_status = FALSE; +ibool srv_stats_on_metadata = TRUE; + ibool srv_use_doublewrite_buf = TRUE; ibool srv_use_checksums = TRUE;