MySQL Reference Manual for version 4.0.18.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.1 MyISAM Tables

MyISAM is the default table type in MySQL Version 3.23. It's based on the ISAM code and has a lot of useful extensions.

The index is stored in a file with the `.MYI' (MYIndex) extension, and the data is stored in a file with the `.MYD' (MYData) extension. You can check/repair MyISAM tables with the myisamchk utility. See section 5.6.2.7 Using myisamchk for Crash Recovery. You can compress MyISAM tables with myisampack to take up much less space. See section myisampack.

The following is new in MyISAM:

MyISAM also supports the following things, which MySQL will be able to use in the near future:

Note that index files are usually much smaller with MyISAM than with ISAM. This means that MyISAM will normally use less system resources than ISAM, but will need more CPU time when inserting data into a compressed index.

The following options to mysqld can be used to change the behavior of MyISAM tables. See section 13.5.3.4 SHOW VARIABLES.

Option Description
--myisam-recover=# Automatic recovery of crashed tables.
-O myisam_sort_buffer_size=# Buffer used when recovering tables.
--delay-key-write=ALL Don't flush key buffers between writes for any MyISAM table
-O myisam_max_extra_sort_file_size=# Used to help MySQL to decide when to use the slow but safe key cache index create method. Note that this parameter is given in megabytes before 4.0.3 and in bytes beginning with this version.
-O myisam_max_sort_file_size=# Don't use the fast sort index method to created index if the temporary file would get bigger than this. Note that this parameter is given in megabytes before 4.0.3 and in bytes beginning with this version.
-O bulk_insert_buffer_size=# Size of tree cache used in bulk insert optimization. Note that this is a limit per thread!

The automatic recovery is activated if you start mysqld with --myisam-recover=#. See section 5.2.1 mysqld Command-line Options. On open, the table is checked if it's marked as crashed or if the open count variable for the table is not 0 and you are running with --skip-external-locking. If either of the above is true the following happens.

If the recover wouldn't be able to recover all rows from a previous completed statement and you didn't specify FORCE as an option to myisam-recover, then the automatic repair will abort with an error message in the error file:

 
Error: Couldn't repair table: test.g00pages

If you in this case had used the FORCE option you would instead have got a warning in the error file:

 
Warning: Found 344 of 354 rows when repairing ./test/g00pages

Note that if you run automatic recovery with the BACKUP option, you should have a cron script that automatically moves file with names like `tablename-datetime.BAK' from the database directories to a backup media.

See section 5.2.1 mysqld Command-line Options.

14.1.1 Space Needed for Keys  
14.1.2 MyISAM Table Formats  
14.1.3 MyISAM Table Problems  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by rdg (Feb 25 2004) using texi2html