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

bulk insert optimization documented

parent 00431368
Loading
Loading
Loading
Loading
+99 −87
Original line number Diff line number Diff line
@@ -20515,8 +20515,6 @@ or INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name
        SET col_name=expression, col_name=expression, ...
or  INSERT [LOW_PRIORITY] [IGNORE] [INTO] tbl_name
        SELECT ...
@end example
@@ -21871,9 +21869,9 @@ The output resembles that shown below, though the format and numbers may
differ somewhat:
@example
+-------------------------+---------------------------+
+------------------------------+---------------------------+
| Variable_name                | Value                     |
+-------------------------+---------------------------+
+------------------------------+---------------------------+
| ansi_mode                    | OFF                       |
| back_log                     | 50                        |
| basedir                      | /my/monty/                |
@@ -21925,6 +21923,7 @@ differ somewhat:
| max_sort_length              | 1024                      |
| max_tmp_tables               | 32                        |
| max_write_lock_count         | 4294967295                |
| myisam_bulk_insert_tree_size | 8388608                   |
| myisam_recover_options       | DEFAULT                   |
| myisam_sort_buffer_size      | 8388608                   |
| net_buffer_length            | 16384                     |
@@ -21953,7 +21952,7 @@ differ somewhat:
| tmpdir                       | /tmp/                     |
| version                      | 3.23.29a-gamma-debug      |
| wait_timeout                 | 28800                     |
+-------------------------+---------------------------+
+------------------------------+---------------------------+
@end example
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
@code{REPAIR} or when creating indexes with @code{CREATE INDEX} or
@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}.
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
@@ -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{--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_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!
@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!
@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
The automatic recovery is activated if you start @code{mysqld} with
@@ -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
multiple value lists @code{INSERT} statements. This is much faster (many
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
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,
@@ -46427,6 +46436,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@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
      @code{ALTER TABLE table_name ENABLE KEYS} commands.
@item
+1 −1
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ int tree_delete(TREE *tree, void *key)
  if (remove_colour == BLACK)
    rb_delete_fixup(tree,parent);
  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));
  tree->elements_in_tree--;
  return 0;