Skip to content

Commit

Permalink
增加参数inception_osc_alter_foreign_keys_method,为了解决pt工具改表时
Browse files Browse the repository at this point in the history
在没有外键的情况下,还是查information schema,导致在库表很多的情况下
非常慢的问题,加上这个参数,默认为none,就不会去查了,速度非常快,并且
可以减少内存的暴涨
  • Loading branch information
zhufeng.wang committed Mar 23, 2016
1 parent d9066ff commit ddbe89f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dbug/dbug.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static BOOLEAN init_done= FALSE; /* Set to TRUE when initialization done */
*/
static struct settings init_settings;
static const char *db_process= 0;/* Pointer to process name; argv[0] */
my_bool _dbug_on_= TRUE; /* FALSE if no debugging at all */
my_bool _dbug_on_= FALSE; /* FALSE if no debugging at all */

typedef struct _db_code_state_ {
const char *process; /* Pointer to process name; usually argv[0] */
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ typedef struct system_variables
bool inception_osc_drop_new_table;
bool inception_osc_check_replication_filters;
bool inception_osc_check_alter;
ulong inception_alter_foreign_keys_method;
ulong inception_osc_chunk_size;
ulong inception_osc_max_running;
ulong inception_osc_max_connected;
Expand Down
6 changes: 5 additions & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const char *xa_state_names[]={
#define INC_CHAR_MAX_TO_VARCHAR 16

extern const char *osc_recursion_method[];
extern const char *osc_alter_foreign_keys_method[];

int mysql_check_subselect_item( THD* thd, st_select_lex *select_lex, bool top);
int mysql_check_item( THD* thd, Item* item, st_select_lex *select_lex);
Expand Down Expand Up @@ -10383,7 +10384,10 @@ int mysql_execute_alter_table_osc(
if (!thd->variables.inception_osc_check_alter)
oscargv[count++] = strdup("--no-check-alter");

oscargv[count++] = strdup("--alter-foreign-keys-method=auto");
sprintf(cmd_line, "--alter-foreign-keys-method=%s",
osc_alter_foreign_keys_method[thd->variables.inception_alter_foreign_keys_method]);
oscargv[count++] = strdup(cmd_line);

oscargv[count++] = strdup("--execute");
oscargv[count++] = strdup("--statistics");
oscargv[count++] = strdup("--max-lag");
Expand Down
10 changes: 10 additions & 0 deletions sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,16 @@ static Sys_var_mybool Sys_inception_osc_check_alter(
SESSION_VAR(inception_osc_check_alter),
CMD_LINE(OPT_ARG), DEFAULT(TRUE));

const char *osc_alter_foreign_keys_method[]=
{"auto", "none", "rebuild_constraints", "drop_swap", NullS};

static Sys_var_enum Sys_inception_alter_foreign_keys_method(
"inception_osc_alter_foreign_keys_method",
"--alter-foreign-keys-method",
SESSION_VAR(inception_alter_foreign_keys_method), CMD_LINE(REQUIRED_ARG),
osc_alter_foreign_keys_method, DEFAULT(alter_foreign_keys_method_none),
NO_MUTEX_GUARD, NOT_IN_BINLOG);

const char *osc_recursion_method[]= {"processlist", "hosts", "none", NullS};
static Sys_var_enum Sys_inception_osc_recursion_method(
"inception_osc_recursion_method",
Expand Down
6 changes: 6 additions & 0 deletions sql/sys_vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -1836,4 +1836,10 @@ enum enum_osc_recursion_method{
recursion_method_unspec=3
};

enum enum_osc_alter_foreign_keys_method{
alter_foreign_keys_method_auto =0,
alter_foreign_keys_method_none =1,
alter_foreign_keys_method_rebuild_constraints=2,
alter_foreign_keys_method_drop_swap =3,
};

0 comments on commit ddbe89f

Please sign in to comment.