Commit f3299061 authored by serg@serg.mysql.com's avatar serg@serg.mysql.com

bulk insert optimization documented

parent 00431368
...@@ -20515,8 +20515,6 @@ or INSERT [LOW_PRIORITY | DELAYED] [IGNORE] ...@@ -20515,8 +20515,6 @@ or INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
or INSERT [LOW_PRIORITY | DELAYED] [IGNORE] or INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
[INTO] tbl_name [INTO] tbl_name
SET col_name=expression, col_name=expression, ... SET col_name=expression, col_name=expression, ...
or INSERT [LOW_PRIORITY] [IGNORE] [INTO] tbl_name
SELECT ...
@end example @end example
...@@ -21871,89 +21869,90 @@ The output resembles that shown below, though the format and numbers may ...@@ -21871,89 +21869,90 @@ The output resembles that shown below, though the format and numbers may
differ somewhat: differ somewhat:
@example @example
+-------------------------+---------------------------+ +------------------------------+---------------------------+
| Variable_name | Value | | Variable_name | Value |
+-------------------------+---------------------------+ +------------------------------+---------------------------+
| ansi_mode | OFF | | ansi_mode | OFF |
| back_log | 50 | | back_log | 50 |
| basedir | /my/monty/ | | basedir | /my/monty/ |
| bdb_cache_size | 16777216 | | bdb_cache_size | 16777216 |
| bdb_log_buffer_size | 32768 | | bdb_log_buffer_size | 32768 |
| bdb_home | /my/monty/data/ | | bdb_home | /my/monty/data/ |
| bdb_max_lock | 10000 | | bdb_max_lock | 10000 |
| bdb_logdir | | | bdb_logdir | |
| bdb_shared_data | OFF | | bdb_shared_data | OFF |
| bdb_tmpdir | /tmp/ | | bdb_tmpdir | /tmp/ |
| binlog_cache_size | 32768 | | binlog_cache_size | 32768 |
| concurrent_insert | ON | | concurrent_insert | ON |
| connect_timeout | 5 | | connect_timeout | 5 |
| datadir | /my/monty/data/ | | datadir | /my/monty/data/ |
| delay_key_write | ON | | delay_key_write | ON |
| delayed_insert_limit | 100 | | delayed_insert_limit | 100 |
| delayed_insert_timeout | 300 | | delayed_insert_timeout | 300 |
| delayed_queue_size | 1000 | | delayed_queue_size | 1000 |
| flush | OFF | | flush | OFF |
| flush_time | 0 | | flush_time | 0 |
| ft_min_word_len | 4 | | ft_min_word_len | 4 |
| ft_max_word_len | 254 | | ft_max_word_len | 254 |
| ft_max_word_len_for_sort| 20 | | ft_max_word_len_for_sort | 20 |
| have_bdb | YES | | have_bdb | YES |
| have_gemini | NO | | have_gemini | NO |
| have_innodb | YES | | have_innodb | YES |
| have_raid | YES | | have_raid | YES |
| have_ssl | NO | | have_ssl | NO |
| init_file | | | init_file | |
| interactive_timeout | 28800 | | interactive_timeout | 28800 |
| join_buffer_size | 131072 | | join_buffer_size | 131072 |
| key_buffer_size | 16776192 | | key_buffer_size | 16776192 |
| language | /my/monty/share/english/ | | language | /my/monty/share/english/ |
| large_files_support | ON | | large_files_support | ON |
| log | OFF | | log | OFF |
| log_update | OFF | | log_update | OFF |
| log_bin | OFF | | log_bin | OFF |
| log_slave_updates | OFF | | log_slave_updates | OFF |
| long_query_time | 10 | | long_query_time | 10 |
| low_priority_updates | OFF | | low_priority_updates | OFF |
| lower_case_table_names | 0 | | lower_case_table_names | 0 |
| max_allowed_packet | 1048576 | | max_allowed_packet | 1048576 |
| max_binlog_cache_size | 4294967295 | | max_binlog_cache_size | 4294967295 |
| max_connections | 100 | | max_connections | 100 |
| max_connect_errors | 10 | | max_connect_errors | 10 |
| max_delayed_threads | 20 | | max_delayed_threads | 20 |
| max_heap_table_size | 16777216 | | max_heap_table_size | 16777216 |
| max_join_size | 4294967295 | | max_join_size | 4294967295 |
| max_sort_length | 1024 | | max_sort_length | 1024 |
| max_tmp_tables | 32 | | max_tmp_tables | 32 |
| max_write_lock_count | 4294967295 | | max_write_lock_count | 4294967295 |
| myisam_recover_options | DEFAULT | | myisam_bulk_insert_tree_size | 8388608 |
| myisam_sort_buffer_size | 8388608 | | myisam_recover_options | DEFAULT |
| net_buffer_length | 16384 | | myisam_sort_buffer_size | 8388608 |
| net_read_timeout | 30 | | net_buffer_length | 16384 |
| net_retry_count | 10 | | net_read_timeout | 30 |
| net_write_timeout | 60 | | net_retry_count | 10 |
| open_files_limit | 0 | | net_write_timeout | 60 |
| pid_file | /my/monty/data/donna.pid | | open_files_limit | 0 |
| port | 3306 | | pid_file | /my/monty/data/donna.pid |
| protocol_version | 10 | | port | 3306 |
| record_buffer | 131072 | | protocol_version | 10 |
| query_buffer_size | 0 | | record_buffer | 131072 |
| safe_show_database | OFF | | query_buffer_size | 0 |
| server_id | 0 | | safe_show_database | OFF |
| skip_locking | ON | | server_id | 0 |
| skip_networking | OFF | | skip_locking | ON |
| skip_show_database | OFF | | skip_networking | OFF |
| slow_launch_time | 2 | | skip_show_database | OFF |
| socket | /tmp/mysql.sock | | slow_launch_time | 2 |
| sort_buffer | 2097116 | | socket | /tmp/mysql.sock |
| table_cache | 64 | | sort_buffer | 2097116 |
| table_type | MYISAM | | table_cache | 64 |
| thread_cache_size | 4 | | table_type | MYISAM |
| thread_stack | 65536 | | thread_cache_size | 4 |
| tmp_table_size | 1048576 | | thread_stack | 65536 |
| tmpdir | /tmp/ | | tmp_table_size | 1048576 |
| version | 3.23.29a-gamma-debug | | tmpdir | /tmp/ |
| wait_timeout | 28800 | | version | 3.23.29a-gamma-debug |
+-------------------------+---------------------------+ | wait_timeout | 28800 |
+------------------------------+---------------------------+
@end example @end example
Each option is described below. Values for buffer sizes, lengths, and stack Each option is described below. Values for buffer sizes, lengths, and stack
...@@ -22262,6 +22261,14 @@ The buffer that is allocated when sorting the index when doing a ...@@ -22262,6 +22261,14 @@ The buffer that is allocated when sorting the index when doing a
@code{REPAIR} or when creating indexes with @code{CREATE INDEX} or @code{REPAIR} or when creating indexes with @code{CREATE INDEX} or
@code{ALTER TABLE}. @code{ALTER TABLE}.
@item @code{myisam_bulk_insert_tree_size}
@strong{MySQL} uses special tree-like cache to make bulk inserts (that is,
@code{INSERT ... SELECT},
@code{INSERT ... VALUES (...), (...), ...}, and
@code{LOAD DATA INFILE}) faster. This variable limits
the size of the cache tree in bytes @strong{per thread, per index}.
Default value is 8 MB.
@item @code{myisam_max_extra_sort_file_size}. @item @code{myisam_max_extra_sort_file_size}.
If the creating of the temporary file for fast index creation would be If the creating of the temporary file for fast index creation would be
this much bigger than using the key cache, then prefer the key cache this much bigger than using the key cache, then prefer the key cache
...@@ -23948,8 +23955,8 @@ The following options to @code{mysqld} can be used to change the behavior of ...@@ -23948,8 +23955,8 @@ The following options to @code{mysqld} can be used to change the behavior of
@item @code{-O myisam_sort_buffer_size=#} @tab Buffer used when recovering tables. @item @code{-O myisam_sort_buffer_size=#} @tab Buffer used when recovering tables.
@item @code{--delay-key-write-for-all-tables} @tab Don't flush key buffers between writes for any MyISAM table @item @code{--delay-key-write-for-all-tables} @tab Don't flush key buffers between writes for any MyISAM table
@item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help @strong{MySQL} to decide when to use the slow but safe key cache index create method. @strong{NOTE} that this parameter is given in megabytes! @item @code{-O myisam_max_extra_sort_file_size=#} @tab Used to help @strong{MySQL} to decide when to use the slow but safe key cache index create method. @strong{NOTE} that this parameter is given in megabytes!
@item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this. @item @code{-O myisam_max_sort_file_size=#} @tab Don't use the fast sort index method to created index if the temporary file would get bigger than this. @strong{NOTE} that this paramter is given in megabytes!
@strong{NOTE} that this paramter is given in megabytes! @item @code{-O myisam_bulk_insert_tree_size=#} @tab Size of tree cache used in bulk insert optimization. @strong{NOTE} that this is a limit @strong{per index}!
@end multitable @end multitable
The automatic recovery is activated if you start @code{mysqld} with The automatic recovery is activated if you start @code{mysqld} with
...@@ -32573,6 +32580,8 @@ Some ways to speed up inserts: ...@@ -32573,6 +32580,8 @@ Some ways to speed up inserts:
If you are inserting many rows from the same client at the same time, use If you are inserting many rows from the same client at the same time, use
multiple value lists @code{INSERT} statements. This is much faster (many multiple value lists @code{INSERT} statements. This is much faster (many
times in some cases) than using separate @code{INSERT} statements. times in some cases) than using separate @code{INSERT} statements.
Tune up @code{myisam_bulk_insert_tree_size} variable to make it even
faster. @xref{SHOW VARIABLES}.
@item @item
If you are inserting a lot of rows from different clients, you can get If you are inserting a lot of rows from different clients, you can get
higher speed by using the @code{INSERT DELAYED} statement. @xref{INSERT, higher speed by using the @code{INSERT DELAYED} statement. @xref{INSERT,
...@@ -46427,6 +46436,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -46427,6 +46436,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
Tree-like cache to speed up bulk inserts and
@code{myisam_bulk_insert_tree_size} variable.
@item
Added @code{ALTER TABLE table_name DISABLE KEYS} and Added @code{ALTER TABLE table_name DISABLE KEYS} and
@code{ALTER TABLE table_name ENABLE KEYS} commands. @code{ALTER TABLE table_name ENABLE KEYS} commands.
@item @item
...@@ -313,7 +313,7 @@ int tree_delete(TREE *tree, void *key) ...@@ -313,7 +313,7 @@ int tree_delete(TREE *tree, void *key)
if (remove_colour == BLACK) if (remove_colour == BLACK)
rb_delete_fixup(tree,parent); rb_delete_fixup(tree,parent);
if (tree->free) if (tree->free)
(*tree->free)(ELEMENT_KEY(tree,element)); (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg);
my_free((gptr) element,MYF(0)); my_free((gptr) element,MYF(0));
tree->elements_in_tree--; tree->elements_in_tree--;
return 0; return 0;
......
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