Commit 52d9a4d3 authored by Mikael Ronstrom's avatar Mikael Ronstrom

WL#4571, Enable Key cache defined for a partition to enable more scalability...

WL#4571, Enable Key cache defined for a partition to enable more scalability on partitioned MyISAM tables among other things
parent 905d715f
...@@ -556,7 +556,7 @@ parse_package() ...@@ -556,7 +556,7 @@ parse_package()
package="pro" package="pro"
;; ;;
extended ) extended )
package="" package="extended"
;; ;;
cge ) cge )
package="cge" package="cge"
......
...@@ -847,9 +847,12 @@ int ha_partition::rename_partitions(const char *path) ...@@ -847,9 +847,12 @@ int ha_partition::rename_partitions(const char *path)
#define ANALYZE_PARTS 2 #define ANALYZE_PARTS 2
#define CHECK_PARTS 3 #define CHECK_PARTS 3
#define REPAIR_PARTS 4 #define REPAIR_PARTS 4
#define ASSIGN_KEYCACHE_PARTS 5
#define PRELOAD_KEYS_PARTS 6
static const char *opt_op_name[]= {NULL, static const char *opt_op_name[]= {NULL,
"optimize", "analyze", "check", "repair" }; "optimize", "analyze", "check", "repair",
"assign_to_keycache", "preload_keys"};
/* /*
Optimize table Optimize table
...@@ -934,7 +937,44 @@ int ha_partition::repair(THD *thd, HA_CHECK_OPT *check_opt) ...@@ -934,7 +937,44 @@ int ha_partition::repair(THD *thd, HA_CHECK_OPT *check_opt)
DBUG_RETURN(handle_opt_partitions(thd, check_opt, REPAIR_PARTS)); DBUG_RETURN(handle_opt_partitions(thd, check_opt, REPAIR_PARTS));
} }
/**
Assign to keycache
@param thd Thread object
@param check_opt Check/analyze/repair/optimize options
@return
@retval >0 Error
@retval 0 Success
*/
int ha_partition::assign_to_keycache(THD *thd, HA_CHECK_OPT *check_opt)
{
DBUG_ENTER("ha_partition::assign_to_keycache");
DBUG_RETURN(handle_opt_partitions(thd, check_opt, ASSIGN_KEYCACHE_PARTS));
}
/**
Preload to keycache
@param thd Thread object
@param check_opt Check/analyze/repair/optimize options
@return
@retval >0 Error
@retval 0 Success
*/
int ha_partition::preload_keys(THD *thd, HA_CHECK_OPT *check_opt)
{
DBUG_ENTER("ha_partition::preload_keys");
DBUG_RETURN(handle_opt_partitions(thd, check_opt, PRELOAD_KEYS_PARTS));
}
/* /*
Handle optimize/analyze/check/repair of one partition Handle optimize/analyze/check/repair of one partition
...@@ -965,6 +1005,10 @@ static int handle_opt_part(THD *thd, HA_CHECK_OPT *check_opt, ...@@ -965,6 +1005,10 @@ static int handle_opt_part(THD *thd, HA_CHECK_OPT *check_opt,
error= file->ha_check(thd, check_opt); error= file->ha_check(thd, check_opt);
else if (flag == REPAIR_PARTS) else if (flag == REPAIR_PARTS)
error= file->ha_repair(thd, check_opt); error= file->ha_repair(thd, check_opt);
else if (flag == ASSIGN_KEYCACHE_PARTS)
error= file->assign_to_keycache(thd, check_opt);
else if (flag == PRELOAD_KEYS_PARTS)
error= file->preload_keys(thd, check_opt);
else else
{ {
DBUG_ASSERT(FALSE); DBUG_ASSERT(FALSE);
...@@ -1094,6 +1138,12 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, ...@@ -1094,6 +1138,12 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
"Subpartition %s returned error", "Subpartition %s returned error",
sub_elem->partition_name); sub_elem->partition_name);
} }
/* reset part_state for the remaining partitions */
do
{
if (part_elem->part_state == PART_ADMIN)
part_elem->part_state= PART_NORMAL;
} while (part_elem= part_it++);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
} while (++j < no_subparts); } while (++j < no_subparts);
...@@ -1120,6 +1170,12 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, ...@@ -1120,6 +1170,12 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
opt_op_name[flag], "Partition %s returned error", opt_op_name[flag], "Partition %s returned error",
part_elem->partition_name); part_elem->partition_name);
} }
/* reset part_state for the remaining partitions */
do
{
if (part_elem->part_state == PART_ADMIN)
part_elem->part_state= PART_NORMAL;
} while (part_elem= part_it++);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
} }
......
...@@ -1061,12 +1061,13 @@ class ha_partition :public handler ...@@ -1061,12 +1061,13 @@ class ha_partition :public handler
virtual int backup(TD* thd, HA_CHECK_OPT *check_opt); virtual int backup(TD* thd, HA_CHECK_OPT *check_opt);
virtual int restore(THD* thd, HA_CHECK_OPT *check_opt); virtual int restore(THD* thd, HA_CHECK_OPT *check_opt);
virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt);
virtual int preload_keys(THD *thd, HA_CHECK_OPT *check_opt);
virtual int dump(THD* thd, int fd = -1); virtual int dump(THD* thd, int fd = -1);
virtual int net_read_dump(NET* net); virtual int net_read_dump(NET* net);
virtual uint checksum() const; virtual uint checksum() const;
*/ */
/* Enabled keycache for performance reasons, WL#4571 */
virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt);
virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt);
/* /*
------------------------------------------------------------------------- -------------------------------------------------------------------------
......
...@@ -32,7 +32,8 @@ enum partition_state { ...@@ -32,7 +32,8 @@ enum partition_state {
PART_REORGED_DROPPED= 5, PART_REORGED_DROPPED= 5,
PART_CHANGED= 6, PART_CHANGED= 6,
PART_IS_CHANGED= 7, PART_IS_CHANGED= 7,
PART_IS_ADDED= 8 PART_IS_ADDED= 8,
PART_ADMIN= 9
}; };
/* /*
......
...@@ -4151,7 +4151,7 @@ uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info, ...@@ -4151,7 +4151,7 @@ uint set_part_state(Alter_info *alter_info, partition_info *tab_part_info,
/* /*
Mark the partition. Mark the partition.
I.e mark the partition as a partition to be "changed" by I.e mark the partition as a partition to be "changed" by
analyzing/optimizing/rebuilding/checking/repairing analyzing/optimizing/rebuilding/checking/repairing/...
*/ */
no_parts_found++; no_parts_found++;
part_elem->part_state= part_state; part_elem->part_state= part_state;
......
...@@ -4521,6 +4521,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -4521,6 +4521,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
/* /*
Set up which partitions that should be processed Set up which partitions that should be processed
if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION .. if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION ..
CACHE INDEX/LOAD INDEX for specified partitions
*/ */
Alter_info *alter_info= &lex->alter_info; Alter_info *alter_info= &lex->alter_info;
......
...@@ -1261,7 +1261,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1261,7 +1261,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
slave master_def master_defs master_file_def slave_until_opts slave master_def master_defs master_file_def slave_until_opts
repair restore backup analyze check start checksum repair restore backup analyze check start checksum
field_list field_list_item field_spec kill column_def key_def field_list field_list_item field_spec kill column_def key_def
keycache_list assign_to_keycache preload_list preload_keys keycache_list keycache_list_or_parts assign_to_keycache
assign_to_keycache_parts
preload_list preload_list_or_parts preload_keys preload_keys_parts
select_item_list select_item values_list no_braces select_item_list select_item values_list no_braces
opt_limit_clause delete_limit_clause fields opt_values values opt_limit_clause delete_limit_clause fields opt_values values
procedure_list procedure_list2 procedure_item procedure_list procedure_list2 procedure_item
...@@ -3747,17 +3749,9 @@ opt_partitioning: ...@@ -3747,17 +3749,9 @@ opt_partitioning:
; ;
partitioning: partitioning:
PARTITION_SYM PARTITION_SYM have_partitioning
{ {
#ifdef WITH_PARTITION_STORAGE_ENGINE
LEX *lex= Lex; LEX *lex= Lex;
LEX_STRING partition_name={C_STRING_WITH_LEN("partition")};
if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN))
{
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--skip-partition");
MYSQL_YYABORT;
}
lex->part_info= new partition_info(); lex->part_info= new partition_info();
if (!lex->part_info) if (!lex->part_info)
{ {
...@@ -3768,14 +3762,27 @@ partitioning: ...@@ -3768,14 +3762,27 @@ partitioning:
{ {
lex->alter_info.flags|= ALTER_PARTITION; lex->alter_info.flags|= ALTER_PARTITION;
} }
}
partition
;
have_partitioning:
/* empty */
{
#ifdef WITH_PARTITION_STORAGE_ENGINE
LEX_STRING partition_name={C_STRING_WITH_LEN("partition")};
if (!plugin_is_ready(&partition_name, MYSQL_STORAGE_ENGINE_PLUGIN))
{
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--skip-partition");
MYSQL_YYABORT;
}
#else #else
my_error(ER_FEATURE_DISABLED, MYF(0), my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"partitioning", "--with-partition"); "--skip-partition");
MYSQL_YYABORT; MYSQL_YYABORT;
#endif #endif
} }
partition
; ;
partition_entry: partition_entry:
...@@ -5437,7 +5444,6 @@ alter: ...@@ -5437,7 +5444,6 @@ alter:
if (!lex->select_lex.add_table_to_list(thd, $4, NULL, if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
TL_OPTION_UPDATING)) TL_OPTION_UPDATING))
MYSQL_YYABORT; MYSQL_YYABORT;
lex->alter_info.reset();
lex->col_list.empty(); lex->col_list.empty();
lex->select_lex.init_order(); lex->select_lex.init_order();
lex->select_lex.db= lex->select_lex.db=
...@@ -6296,14 +6302,23 @@ table_to_table: ...@@ -6296,14 +6302,23 @@ table_to_table:
; ;
keycache: keycache:
CACHE_SYM INDEX_SYM keycache_list IN_SYM key_cache_name CACHE_SYM INDEX_SYM
{
Lex->alter_info.reset();
}
keycache_list_or_parts IN_SYM key_cache_name
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE; lex->sql_command= SQLCOM_ASSIGN_TO_KEYCACHE;
lex->ident= $5; lex->ident= $6;
} }
; ;
keycache_list_or_parts:
keycache_list
| assign_to_keycache_parts
;
keycache_list: keycache_list:
assign_to_keycache assign_to_keycache
| keycache_list ',' assign_to_keycache | keycache_list ',' assign_to_keycache
...@@ -6318,6 +6333,15 @@ assign_to_keycache: ...@@ -6318,6 +6333,15 @@ assign_to_keycache:
} }
; ;
assign_to_keycache_parts:
table_ident adm_partition cache_keys_spec
{
if (!Select->add_table_to_list(YYTHD, $1, NULL, 0, TL_READ,
Select->pop_index_hints()))
MYSQL_YYABORT;
}
;
key_cache_name: key_cache_name:
ident { $$= $1; } ident { $$= $1; }
| DEFAULT { $$ = default_key_cache_base; } | DEFAULT { $$ = default_key_cache_base; }
...@@ -6328,11 +6352,17 @@ preload: ...@@ -6328,11 +6352,17 @@ preload:
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command=SQLCOM_PRELOAD_KEYS; lex->sql_command=SQLCOM_PRELOAD_KEYS;
lex->alter_info.reset();
} }
preload_list preload_list_or_parts
{} {}
; ;
preload_list_or_parts:
preload_keys_parts
| preload_list
;
preload_list: preload_list:
preload_keys preload_keys
| preload_list ',' preload_keys | preload_list ',' preload_keys
...@@ -6347,6 +6377,23 @@ preload_keys: ...@@ -6347,6 +6377,23 @@ preload_keys:
} }
; ;
preload_keys_parts:
table_ident adm_partition cache_keys_spec opt_ignore_leaves
{
if (!Select->add_table_to_list(YYTHD, $1, NULL, $4, TL_READ,
Select->pop_index_hints()))
MYSQL_YYABORT;
}
;
adm_partition:
PARTITION_SYM have_partitioning
{
Lex->alter_info.flags|= ALTER_ADMIN_PARTITION;
}
'(' all_or_alt_part_name_list ')'
;
cache_keys_spec: cache_keys_spec:
{ {
Lex->select_lex.alloc_index_hints(YYTHD); Lex->select_lex.alloc_index_hints(YYTHD);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment