Oracle 5.0 Reference Manual page 706

Table of Contents

Advertisement

faster in some cases) than using separate single-row
to a nonempty table, you can tune the
insertion even faster. See
• If multiple clients are inserting a lot of rows, you can get higher speed by using the
statement. See
DELAYED
• For a
table, you can use concurrent inserts to add rows at the same time that
MyISAM
statements are running, if there are no deleted rows in middle of the data file. See
"Concurrent
Inserts".
• When loading a table from a text file, use
using
statements. See
INSERT
• With some extra work, it is possible to make
table when the table has many indexes. Use the following procedure:
1. Optionally create the table with
2. Execute a
FLUSH TABLES
3. Use
myisamchk --keys-used=0 -rq /path/to/db/tbl_name.
indexes for the table.
4. Insert data into the table with
therefore is very fast.
5. If you intend only to read from the table in the future, use
Section 14.1.3.3, "Compressed Table
6. Re-create the indexes with
tree in memory before writing it to disk, which is much faster that updating the index during
because it avoids lots of disk seeks. The resulting index tree is also perfectly
DATA INFILE
balanced.
7. Execute a
FLUSH TABLES
LOAD DATA INFILE
which you insert data is empty. The main difference between automatic optimization and using the
procedure explicitly is that you can let
index creation than you might want the server to allocate for index re-creation when it executes the
LOAD DATA INFILE
You can also disable or enable the nonunique indexes for a
statements rather than myisamchk. If you use these statements, you can skip the
operations:
ALTER TABLE
tbl_name
ALTER TABLE
tbl_name
• To speed up
INSERT
tables, lock your tables:
LOCK TABLES a WRITE;
INSERT INTO a VALUES (1,23),(2,34),(4,33);
INSERT INTO a VALUES (8,26),(6,29);
...
UNLOCK TABLES;
This benefits performance because the index buffer is flushed to disk only once, after all
statements have completed. Normally, there would be as many index buffer flushes as there are
statements. Explicit locking statements are not needed if you can insert all rows with a
INSERT
single INSERT.
Optimizing
Non-SELECT
bulk_insert_buffer_size
Section 5.1.4, "Server System
Section 13.2.5.2,
"INSERT DELAYED
LOAD DATA
Section 13.2.6,
CREATE
statement or a
LOAD DATA
Characteristics".
myisamchk -rq
statement or a
performs the preceding optimization automatically if the
myisamchk
statement.
DISABLE KEYS;
ENABLE KEYS;
operations that are performed with multiple statements for nontransactional
686
Statements
statements. If you are adding data
INSERT
Variables".
Syntax".
INFILE. This is usually 20 times faster than
"LOAD DATA INFILE
run even faster for a
LOAD DATA INFILE
TABLE.
mysqladmin flush-tables
INFILE. This does not update any indexes and
myisampack
/path/to/db/tbl_name. This creates the index
mysqladmin flush-tables
allocate much more temporary memory for the
MyISAM
[441]
variable to make data
INSERT
SELECT
Section 8.7.3,
Syntax".
MyISAM
command.
This removes all use of
to compress it. See
command.
table into
MyISAM
table by using the following
FLUSH TABLE
INSERT
LOAD

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents