NOT NULL if possible. It makes everything faster and you save one
bit per column.
MEDIUMINT is often better than INT.
VARCHAR columns, a fixed size record format
will be used. This is much faster but may unfortunately waste some
space. See section What are the different row formats? Or when to use VARCHAR/CHAR?.
isamchk --analyze
on the table once it is loaded with relevant data. This updates a value for
each index that tells how many rows that have the same value for this index on
average. Of course, this is always 1 for unique indexes.
isamchk --sort-index --sort-records=1
(if you want to sort on index 1). If you have a unique index from which
you want to read all records in numeric order, this is a good way to
make that faster.
LOAD DATA FROM INFILE. This is
usually 20 times faster than using a lot of INSERTs. If the text file
isn't on the server, rcp it to the server first. See section LOAD DATA INFILE syntax.
You can even get more speed when loading data to tables with many indexes
by doing:
CREATE TABLE...
mysqladmin refresh.
isamchk --keys-used=0 database/table_name. This will remove all
usage of all indexes from the table.
LOAD DATA INFILE....
isamchk -r -q database/table_name.
mysqladmin refresh.
LOAD DATA FROM INFILE and INSERT is to enlarge the key buffer.
This can be done with the -O key_buffer=# option to (safe)mysqld.
For example 16M should be a good value if you have much RAM :)
SELECT ... INTO OUTFILE. See section LOAD DATA INFILE syntax.
LOCK TABLES on the tables. ...FROM INFILE... and
...INTO OUTFILE... are atomic so you don't have to use
LOCK TABLES when using these. See section LOCK TABLES syntax.
To check how you are doing, run isamchk -evi on the .ISM
file. @c See section The MySQL table check, optimise and repair program.
Go to the first, previous, next, last section, table of contents.