mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Try to optimize the cache buffer size needed for bulk_insert
Fix for shutdown on Mac OS X
This commit is contained in:
parent
f9e6ae6f42
commit
e65ddf3fc3
11 changed files with 48 additions and 18 deletions
|
@ -76,6 +76,8 @@ int tree_walk(TREE *tree,tree_walk_action action,
|
|||
void *argument, TREE_WALK visit);
|
||||
int tree_delete(TREE *tree,void *key);
|
||||
|
||||
#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -842,8 +842,9 @@ int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
|
|||
{
|
||||
params->info=info;
|
||||
params->keynr=i;
|
||||
/* Only allocate a 16'th of the buffer at a time */
|
||||
init_tree(&info->bulk_insert[i],
|
||||
cache_size / num_keys / 4 + 10,
|
||||
cache_size / num_keys / 16 + 10,
|
||||
cache_size / num_keys, 0,
|
||||
(qsort_cmp2)keys_compare, 0,
|
||||
(tree_element_free) keys_free, (void *)params++);
|
||||
|
|
|
@ -133,11 +133,11 @@ id parent_id level
|
|||
1202 107 2
|
||||
1204 107 2
|
||||
update ignore t1 set id=1023 where id=1010;
|
||||
select * from t1 where parent_id=102;
|
||||
select * from t1 where parent_id=102 order by parent_id,id;
|
||||
id parent_id level
|
||||
1008 102 2
|
||||
1015 102 2
|
||||
1010 102 2
|
||||
1015 102 2
|
||||
explain select level from t1 where level=1;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ref level level 1 const 1 Using where; Using index
|
||||
|
|
|
@ -39,7 +39,7 @@ select * from t1;
|
|||
update ignore t1 set id=id+1; # This will change all rows
|
||||
select * from t1;
|
||||
update ignore t1 set id=1023 where id=1010;
|
||||
select * from t1 where parent_id=102;
|
||||
select * from t1 where parent_id=102 order by parent_id,id;
|
||||
explain select level from t1 where level=1;
|
||||
explain select level,id from t1 where level=1;
|
||||
explain select level,id,parent_id from t1 where level=1;
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
|
||||
#define BLACK 1
|
||||
#define RED 0
|
||||
#define DEFAULT_ALLOC_SIZE (8192-MALLOC_OVERHEAD)
|
||||
#define DEFAULT_ALLOC_SIZE 8192
|
||||
#define DEFAULT_ALIGN_SIZE 8192
|
||||
|
||||
static void delete_tree_element(TREE *,TREE_ELEMENT *);
|
||||
static int tree_walk_left_root_right(TREE *,TREE_ELEMENT *,
|
||||
|
@ -72,8 +73,9 @@ void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
|
|||
DBUG_ENTER("init_tree");
|
||||
DBUG_PRINT("enter",("tree: %lx size: %d",tree,size));
|
||||
|
||||
if (!default_alloc_size)
|
||||
default_alloc_size= DEFAULT_ALLOC_SIZE;
|
||||
if (default_alloc_size < DEFAULT_ALLOC_SIZE)
|
||||
default_alloc_size= DEFAULT_ALLOC_SIZE;
|
||||
default_alloc_size= MY_ALIGN(default_alloc_size, DEFAULT_ALIGN_SIZE);
|
||||
bzero((gptr) &tree->null_element,sizeof(tree->null_element));
|
||||
tree->root= &tree->null_element;
|
||||
tree->compare=compare;
|
||||
|
|
|
@ -83,6 +83,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
|
|||
*/
|
||||
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (16L*1024*1024)
|
||||
#define MIN_ROWS_TO_USE_TABLE_CACHE 100
|
||||
#define MIN_ROWS_TO_USE_BULK_INSERT 100
|
||||
|
||||
/*
|
||||
The following is used to decide if MySQL should use table scanning
|
||||
|
@ -707,7 +708,7 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list);
|
|||
/* old unireg functions */
|
||||
|
||||
void unireg_init(ulong options);
|
||||
void unireg_end(int signal);
|
||||
void unireg_end(void);
|
||||
int rea_create_table(my_string file_name,HA_CREATE_INFO *create_info,
|
||||
List<create_field> &create_field,
|
||||
uint key_count,KEY *key_info);
|
||||
|
|
|
@ -764,7 +764,7 @@ static void __cdecl kill_server(int sig_ptr)
|
|||
if (sig != MYSQL_KILL_SIGNAL && sig != 0)
|
||||
unireg_abort(1); /* purecov: inspected */
|
||||
else
|
||||
unireg_end(0);
|
||||
unireg_end();
|
||||
pthread_exit(0); /* purecov: deadcode */
|
||||
RETURN_FROM_KILL_SERVER;
|
||||
}
|
||||
|
@ -803,12 +803,29 @@ extern "C" sig_handler print_signal_warning(int sig)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
cleanup all memory and end program nicely
|
||||
|
||||
void unireg_end(int signal_number __attribute__((unused)))
|
||||
SYNOPSIS
|
||||
unireg_end()
|
||||
|
||||
NOTES
|
||||
This function never returns.
|
||||
|
||||
If SIGNALS_DONT_BREAK_READ is defined, this function is called
|
||||
by the main thread. To get MySQL to shut down nicely in this case
|
||||
(Mac OS X) we have to call exit() instead if pthread_exit().
|
||||
*/
|
||||
|
||||
void unireg_end(void)
|
||||
{
|
||||
clean_up();
|
||||
my_thread_end();
|
||||
#ifdef SIGNALS_DONT_BREAK_READ
|
||||
exit(0);
|
||||
#else
|
||||
pthread_exit(0); // Exit is in main thread
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -194,15 +194,19 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
|
|||
thd->proc_info="update";
|
||||
if (duplic == DUP_IGNORE || duplic == DUP_REPLACE)
|
||||
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
|
||||
if ((bulk_insert= (values_list.elements > 1 &&
|
||||
if ((bulk_insert= (values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT &&
|
||||
lock_type != TL_WRITE_DELAYED &&
|
||||
!(specialflag & SPECIAL_SAFE_MODE))))
|
||||
{
|
||||
table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
|
||||
thd->variables.read_buff_size);
|
||||
min(thd->variables.read_buff_size,
|
||||
table->avg_row_length*values_list.elements));
|
||||
if (thd->variables.bulk_insert_buff_size)
|
||||
table->file->extra_opt(HA_EXTRA_BULK_INSERT_BEGIN,
|
||||
thd->variables.bulk_insert_buff_size);
|
||||
min(thd->variables.bulk_insert_buff_size,
|
||||
(table->total_key_length +
|
||||
table->keys * TREE_ELEMENT_EXTRA_SIZE)*
|
||||
values_list.elements));
|
||||
table->bulk_insert= 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -3107,12 +3107,13 @@ ident:
|
|||
IDENT { $$=$1; }
|
||||
| keyword
|
||||
{
|
||||
LEX *lex;
|
||||
$$.str=sql_strmake($1.str,$1.length);
|
||||
LEX *lex= Lex;
|
||||
$$.str= lex->thd->strmake($1.str,$1.length);
|
||||
$$.length=$1.length;
|
||||
if ((lex=Lex)->next_state != STATE_END)
|
||||
if (lex->next_state != STATE_END)
|
||||
lex->next_state=STATE_OPERATOR_OR_IDENT;
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
ident_or_text:
|
||||
ident { $$=$1;}
|
||||
|
|
|
@ -143,7 +143,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||
goto err_not_open; /* purecov: inspected */
|
||||
bzero((char*) keyinfo,n_length);
|
||||
outparam->key_info=keyinfo;
|
||||
outparam->max_key_length=0;
|
||||
outparam->max_key_length= outparam->total_key_length= 0;
|
||||
key_part= (KEY_PART_INFO*) (keyinfo+keys);
|
||||
strpos=disk_buff+6;
|
||||
|
||||
|
@ -201,6 +201,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||
}
|
||||
set_if_bigger(outparam->max_key_length,keyinfo->key_length+
|
||||
keyinfo->key_parts);
|
||||
outparam->total_key_length+= keyinfo->key_length;
|
||||
if (keyinfo->flags & HA_NOSAME)
|
||||
set_if_bigger(outparam->max_unique_length,keyinfo->key_length);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ struct st_table {
|
|||
uint reclength; /* Recordlength */
|
||||
uint rec_buff_length;
|
||||
uint keys,key_parts,primary_key,max_key_length,max_unique_length;
|
||||
uint total_key_length;
|
||||
uint uniques;
|
||||
uint null_fields; /* number of null fields */
|
||||
uint blob_fields; /* number of blob fields */
|
||||
|
|
Loading…
Add table
Reference in a new issue