2
.\" Title: \fBmyisamchk\fR
3
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
4
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
6
.\" Manual: MySQL Database System
10
.TH "\FBMYISAMCHK\FR" "1" "11/15/2013" "MySQL 5\&.6" "MySQL Database System"
11
.\" -----------------------------------------------------------------
12
.\" * Define some portability stuff
13
.\" -----------------------------------------------------------------
14
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
.\" http://bugs.debian.org/507673
16
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
.\" -----------------------------------------------------------------
21
.\" * set default formatting
22
.\" -----------------------------------------------------------------
23
.\" disable hyphenation
25
.\" disable justification (adjust text to left margin only)
27
.\" -----------------------------------------------------------------
28
.\" * MAIN CONTENT STARTS HERE *
29
.\" -----------------------------------------------------------------
32
myisamchk \- MyISAM table\-maintenance utility
34
.HP \w'\fBmyisamchk\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fItbl_name\fR\fR\fB\ \&.\&.\&.\fR\ 'u
35
\fBmyisamchk [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fItbl_name\fR\fR\fB \&.\&.\&.\fR
40
utility gets information about your database tables or checks, repairs, or optimizes them\&.
44
tables (tables that have
48
files for storing data and indexes)\&.
54
statements to check and repair
57
Section\ \&13.7.2.2, \(lqCHECK TABLE Syntax\(rq, and
58
Section\ \&13.7.2.5, \(lqREPAIR TABLE Syntax\(rq\&.
62
with partitioned tables is not supported\&.
68
.nr an-no-space-flag 1
76
It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss\&. Possible causes include but are not limited to file system errors\&.
88
shell> \fBmyisamchk [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fItbl_name\fR\fR\fB \&.\&.\&.\fR
98
to do\&. They are described in the following sections\&. You can also get a list of options by invoking
99
\fBmyisamchk \-\-help\fR\&.
103
simply checks your table as the default operation\&. To get more information or to tell
105
to take corrective action, specify options as described in the following discussion\&.
108
is the database table you want to check or repair\&. If you run
110
somewhere other than in the database directory, you must specify the path to the database directory, because
112
has no idea where the database is located\&. In fact,
114
does not actually care whether the files you are working on are located in a database directory\&. You can copy the files that correspond to a database table into some other location and perform recovery operations on them there\&.
116
You can name several tables on the
118
command line if you wish\&. You can also specify a table by naming its index file (the file with the
120
suffix)\&. This enables you to specify all tables in a directory by using the pattern
121
*\&.MYI\&. For example, if you are in a database directory, you can check all the
123
tables in that directory like this:
129
shell> \fBmyisamchk *\&.MYI\fR
135
If you are not in the database directory, you can check all the tables there by specifying the path to the directory:
141
shell> \fBmyisamchk \fR\fB\fI/path/to/database_dir/\fR\fR\fB*\&.MYI\fR
147
You can even check all tables in all databases by specifying a wildcard with the path to the MySQL data directory:
153
shell> \fBmyisamchk \fR\fB\fI/path/to/datadir/*/*\fR\fR\fB\&.MYI\fR
159
The recommended way to quickly check all
167
shell> \fBmyisamchk \-\-silent \-\-fast \fR\fB\fI/path/to/datadir/*/*\fR\fR\fB\&.MYI\fR
173
If you want to check all
175
tables and repair any that are corrupted, you can use the following command:
181
shell> \fBmyisamchk \-\-silent \-\-force \-\-fast \-\-update\-state \e\fR
182
\fB\-\-key_buffer_size=64M \-\-myisam_sort_buffer_size=64M \e\fR
183
\fB\-\-read_buffer_size=1M \-\-write_buffer_size=1M \e\fR
184
\fB\fI/path/to/datadir/*/*\fR\fR\fB\&.MYI\fR
190
This command assumes that you have more than 64MB free\&. For more information about memory allocation with
192
the section called \(lqMYISAMCHK MEMORY USAGE\(rq\&.
194
For additional information about using
196
Section\ \&7.6, \(lqMyISAM Table Maintenance and Crash Recovery\(rq\&.
202
.nr an-no-space-flag 1
210
\fIYou must ensure that no other program is using the tables while you are running \fR\fI\fBmyisamchk\fR\fR\&. The most effective means of doing so is to shut down the MySQL server while running
211
\fBmyisamchk\fR, or to lock all tables that
215
Otherwise, when you run
216
\fBmyisamchk\fR, it may display the following error message:
222
warning: clients are using or haven\*(Aqt closed the table properly
228
This means that you are trying to check a table that has been updated by another program (such as the
230
server) that hasn\*(Aqt yet closed the file or that has died without closing the file properly, which can sometimes lead to the corruption of one or more
236
is running, you must force it to flush any table modifications that are still buffered in memory by using
237
FLUSH TABLES\&. You should then ensure that no one is using the tables while you are running
240
However, the easiest way to avoid this problem is to use
244
to check tables\&. See
245
Section\ \&13.7.2.2, \(lqCHECK TABLE Syntax\(rq\&.
250
supports the following options, which can be specified on the command line or in the
252
group of an option file\&.
254
also supports the options for processing option files described at
255
Section\ \&4.2.3.4, \(lqCommand-Line Options that Affect Option-File Handling\(rq\&.
256
.SH "MYISAMCHK GENERAL OPTIONS"
257
.\" options: myisamchk
258
.\" myisamchk: options
260
The options described in this section can be used for any type of table maintenance operation performed by
261
\fBmyisamchk\fR\&. The sections following this one describe options that pertain only to specific operations, such as table checking or repairing\&.
271
.\" myisamchk: help option.\" help option: myisamchk\fB\-\-help\fR,
274
Display a help message and exit\&. Options are grouped by type of operation\&.
285
.\" myisamchk: HELP option.\" HELP option: myisamchk\fB\-\-HELP\fR,
288
Display a help message and exit\&. Options are presented in a single list\&.
299
.\" myisamchk: debug option.\" debug option: myisamchk\fB\-\-debug=\fR\fB\fIdebug_options\fR\fR,
300
\fB\-# \fR\fB\fIdebug_options\fR\fR
302
Write a debugging log\&. A typical
305
\*(Aqd:t:o,\fIfile_name\fR\*(Aq\&. The default is
306
\*(Aqd:t:o,/tmp/myisamchk\&.trace\*(Aq\&.
317
.\" myisamchk: silent option.\" silent option: myisamchk\fB\-\-silent\fR,
320
Silent mode\&. Write output only when errors occur\&. You can use
322
twice (\fB\-ss\fR) to make
335
.\" myisamchk: verbose option.\" verbose option: myisamchk\fB\-\-verbose\fR,
338
Verbose mode\&. Print more information about what the program does\&. This can be used with
343
multiple times (\fB\-vv\fR,
344
\fB\-vvv\fR) for even more output\&.
355
.\" myisamchk: version option.\" version option: myisamchk\fB\-\-version\fR,
358
Display version information and exit\&.
369
.\" myisamchk: wait option.\" wait option: myisamchk\fB\-\-wait\fR,
372
Instead of terminating with an error if the table is locked, wait until the table is unlocked before continuing\&. If you are running
374
with external locking disabled, the table can be locked only by another
379
You can also set the following variables by using
380
\fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR
382
.\" decode_bits myisamchk variable
383
.\" ft_max_word_len myisamchk variable
384
.\" ft_min_word_len myisamchk variable
385
.\" ft_stopword_file myisamchk variable
386
.\" key_buffer_size myisamchk variable
387
.\" myisam_block_size myisamchk variable
388
.\" read_buffer_size myisamchk variable
389
.\" sort_buffer_size myisamchk variable
390
.\" myisam_sort_buffer_size myisamchk variable
391
.\" sort_key_blocks myisamchk variable
392
.\" stats_method myisamchk variable
393
.\" write_buffer_size myisamchk variable
446
myisam_sort_key_blocks
480
variables and their default values can be examined with
481
\fBmyisamchk \-\-help\fR:
484
is used when the keys are repaired by sorting keys, which is the normal case when you use
485
\fB\-\-recover\fR\&. As of MySQL 5\&.6\&.9,
486
myisam_sort_buffer_size
487
is available as an alternative name to
489
myisam_sort_buffer_size
492
because its name corresponds to the
493
myisam_sort_buffer_size
494
server system variable that has a similar meaning\&.
496
should be considered deprecated\&.
499
is used when you are checking the table with
500
\fB\-\-extend\-check\fR
501
or when the keys are repaired by inserting keys row by row into the table (like when doing normal inserts)\&. Repairing through the key buffer is used in the following cases:
512
\fB\-\-safe\-recover\fR\&.
523
The temporary files needed to sort the keys would be more than twice as big as when creating the key file directly\&. This is often the case when you have large key values for
527
columns, because the sort operation needs to store the complete key values as it proceeds\&. If you have lots of temporary space and you can force
529
to repair by sorting, you can use the
530
\fB\-\-sort\-recover\fR
534
Repairing through the key buffer takes much less disk space than using sorting, but is also much slower\&.
536
If you want a faster repair, set the
539
myisam_sort_buffer_size
540
variables to about 25% of your available memory\&. You can set both variables to large values, because only one of them is used at a time\&.
543
is the size used for index blocks\&.
548
values are treated for index statistics collection when the
550
option is given\&. It acts like the
552
system variable\&. For more information, see the description of
555
Section\ \&5.1.4, \(lqServer System Variables\(rq, and
556
Section\ \&8.3.7, \(lqInnoDB and MyISAM Index Statistics Collection\(rq\&.
561
indicate the minimum and maximum word length for
567
names the stopword file\&. These need to be set under the following circumstances\&.
571
to perform an operation that modifies table indexes (such as repair or analyze), the
573
indexes are rebuilt using the default full\-text parameter values for minimum and maximum word length and the stopword file unless you specify otherwise\&. This can result in queries failing\&.
575
The problem occurs because these parameters are known only by the server\&. They are not stored in
577
index files\&. To avoid the problem if you have modified the minimum or maximum word length or the stopword file in the server, specify the same
584
\fBmysqld\fR\&. For example, if you have set the minimum word length to 3, you can repair a table with
592
shell> \fBmyisamchk \-\-recover \-\-ft_min_word_len=3 \fR\fB\fItbl_name\fR\fR\fB\&.MYI\fR
600
and the server use the same values for full\-text parameters, you can place each one in both the
604
sections of an option file:
619
An alternative to using
625
ALTER TABLE\&. These statements are performed by the server, which knows the proper full\-text parameter values to use\&.
626
.SH "MYISAMCHK CHECK OPTIONS"
627
.\" check options: myisamchk
631
supports the following options for table checking operations:
641
.\" myisamchk: check option.\" check option: myisamchk\fB\-\-check\fR,
644
Check the table for errors\&. This is the default operation if you specify no option that selects an operation type explicitly\&.
655
.\" myisamchk: check-only-changed option.\" check-only-changed option: myisamchk\fB\-\-check\-only\-changed\fR,
658
Check only tables that have changed since the last check\&.
669
.\" myisamchk: extend-check option.\" extend-check option: myisamchk\fB\-\-extend\-check\fR,
672
Check the table very thoroughly\&. This is quite slow if the table has many indexes\&. This option should only be used in extreme cases\&. Normally,
675
\fBmyisamchk \-\-medium\-check\fR
676
should be able to determine whether there are any errors in the table\&.
679
\fB\-\-extend\-check\fR
680
and have plenty of memory, setting the
682
variable to a large value helps the repair operation run faster\&.
684
See also the description of this option under table repair options\&.
686
For a description of the output format, see
687
the section called \(lqOBTAINING TABLE INFORMATION WITH MYISAMCHK\(rq\&.
698
.\" myisamchk: fast option.\" fast option: myisamchk\fB\-\-fast\fR,
701
Check only tables that haven\*(Aqt been closed properly\&.
712
.\" myisamchk: force option.\" force option: myisamchk\fB\-\-force\fR,
715
Do a repair operation automatically if
717
finds any errors in the table\&. The repair type is the same as that specified with the
732
.\" myisamchk: information option.\" information option: myisamchk\fB\-\-information\fR,
735
Print informational statistics about the table that is checked\&.
746
.\" myisamchk: medium-check option.\" medium-check option: myisamchk\fB\-\-medium\-check\fR,
749
Do a check that is faster than an
750
\fB\-\-extend\-check\fR
751
operation\&. This finds only 99\&.99% of all errors, which should be good enough in most cases\&.
762
.\" myisamchk: read-only option.\" read-only option: myisamchk\fB\-\-read\-only\fR,
765
Do not mark the table as checked\&. This is useful if you use
767
to check a table that is in use by some other application that does not use locking, such as
769
when run with external locking disabled\&.
780
.\" myisamchk: update-state option.\" update-state option: myisamchk\fB\-\-update\-state\fR,
783
Store information in the
785
file to indicate when the table was checked and whether the table crashed\&. This should be used to get full benefit of the
786
\fB\-\-check\-only\-changed\fR
787
option, but you shouldn\*(Aqt use this option if the
789
server is using the table and you are running it with external locking disabled\&.
791
.SH "MYISAMCHK REPAIR OPTIONS"
792
.\" repair options: myisamchk
796
supports the following options for table repair operations (operations performed when an option such as
799
\fB\-\-safe\-recover\fR
810
.\" myisamchk: backup option.\" backup option: myisamchk\fB\-\-backup\fR,
816
\fIfile_name\fR\-\fItime\fR\&.BAK
827
.\" myisamchk: character-sets-dir option.\" character-sets-dir option: myisamchk\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
829
The directory where character sets are installed\&. See
830
Section\ \&10.5, \(lqCharacter Set Configuration\(rq\&.
841
.\" myisamchk: correct-checksum option.\" correct-checksum option: myisamchk\fB\-\-correct\-checksum\fR
843
Correct the checksum information for the table\&.
854
.\" myisamchk: data-file-length option.\" data-file-length option: myisamchk\fB\-\-data\-file\-length=\fR\fB\fIlen\fR\fR,
855
\fB\-D \fR\fB\fIlen\fR\fR
857
The maximum length of the data file (when re\-creating data file when it is
869
.\" myisamchk: extend-check option.\" extend-check option: myisamchk\fB\-\-extend\-check\fR,
872
Do a repair that tries to recover every possible row from the data file\&. Normally, this also finds a lot of garbage rows\&. Do not use this option unless you are desperate\&.
874
See also the description of this option under table checking options\&.
876
For a description of the output format, see
877
the section called \(lqOBTAINING TABLE INFORMATION WITH MYISAMCHK\(rq\&.
888
.\" myisamchk: force option.\" force option: myisamchk\fB\-\-force\fR,
891
Overwrite old intermediate files (files with names like
892
\fItbl_name\fR\&.TMD) instead of aborting\&.
903
.\" myisamchk: keys-used option.\" keys-used option: myisamchk\fB\-\-keys\-used=\fR\fB\fIval\fR\fR,
904
\fB\-k \fR\fB\fIval\fR\fR
907
\fBmyisamchk\fR, the option value is a bit\-value that indicates which indexes to update\&. Each binary bit of the option value corresponds to a table index, where the first index is bit 0\&. An option value of 0 disables updates to all indexes, which can be used to get faster inserts\&. Deactivated indexes can be reactivated by using
908
\fBmyisamchk \-r\fR\&.
919
.\" myisamchk: no-symlinks option.\" no-symlinks option: myisamchk\fB\-\-no\-symlinks\fR,
922
Do not follow symbolic links\&. Normally
924
repairs the table that a symlink points to\&. This option does not exist as of MySQL 4\&.0 because versions from 4\&.0 on do not remove symlinks during repair operations\&.
935
.\" myisamchk: max-record-length option.\" max-record-length option: myisamchk\fB\-\-max\-record\-length=\fR\fB\fIlen\fR\fR
937
Skip rows larger than the given length if
939
cannot allocate memory to hold them\&.
950
.\" myisamchk: parallel-recover option.\" parallel-recover option: myisamchk\fB\-\-parallel\-recover\fR,
953
Use the same technique as
956
\fB\-n\fR, but create all the keys in parallel, using different threads\&.
957
\fIThis is beta\-quality code\&. Use at your own risk!\fR
968
.\" myisamchk: quick option.\" quick option: myisamchk\fB\-\-quick\fR,
971
Achieve a faster repair by modifying only the index file, not the data file\&. You can specify this option twice to force
973
to modify the original data file in case of duplicate keys\&.
984
.\" myisamchk: recover option.\" recover option: myisamchk\fB\-\-recover\fR,
987
Do a repair that can fix almost any problem except unique keys that are not unique (which is an extremely unlikely error with
989
tables)\&. If you want to recover a table, this is the option to try first\&. You should try
990
\fB\-\-safe\-recover\fR
993
reports that the table cannot be recovered using
994
\fB\-\-recover\fR\&. (In the unlikely case that
996
fails, the data file remains intact\&.)
998
If you have lots of memory, you should increase the value of
999
myisam_sort_buffer_size\&.
1004
\h'-04'\(bu\h'+03'\c
1010
.\" myisamchk: safe-recover option.\" safe-recover option: myisamchk\fB\-\-safe\-recover\fR,
1013
Do a repair using an old recovery method that reads through all rows in order and updates all index trees based on the rows found\&. This is an order of magnitude slower than
1014
\fB\-\-recover\fR, but can handle a couple of very unlikely cases that
1016
cannot\&. This recovery method also uses much less disk space than
1017
\fB\-\-recover\fR\&. Normally, you should repair first using
1018
\fB\-\-recover\fR, and then with
1019
\fB\-\-safe\-recover\fR
1024
If you have lots of memory, you should increase the value of
1030
\h'-04'\(bu\h'+03'\c
1036
.\" myisamchk: set-character-set option.\" set-character-set option: myisamchk\fB\-\-set\-character\-set=\fR\fB\fIname\fR\fR
1038
Change the character set used by the table indexes\&. This option was replaced by
1039
\fB\-\-set\-collation\fR
1040
in MySQL 5\&.0\&.3\&.
1045
\h'-04'\(bu\h'+03'\c
1051
.\" myisamchk: set-collation option.\" set-collation option: myisamchk\fB\-\-set\-collation=\fR\fB\fIname\fR\fR
1053
Specify the collation to use for sorting table indexes\&. The character set name is implied by the first part of the collation name\&.
1058
\h'-04'\(bu\h'+03'\c
1064
.\" myisamchk: sort-recover option.\" sort-recover option: myisamchk\fB\-\-sort\-recover\fR,
1069
to use sorting to resolve the keys even if the temporary files would be very large\&.
1074
\h'-04'\(bu\h'+03'\c
1080
.\" myisamchk: tmpdir option.\" tmpdir option: myisamchk\fB\-\-tmpdir=\fR\fB\fIpath\fR\fR,
1081
\fB\-t \fR\fB\fIpath\fR\fR
1083
The path of the directory to be used for storing temporary files\&. If this is not set,
1085
uses the value of the
1087
environment variable\&.
1089
can be set to a list of directory paths that are used successively in round\-robin fashion for creating temporary files\&. The separator character between directory names is the colon (\(lq:\(rq) on Unix and the semicolon (\(lq;\(rq) on Windows\&.
1094
\h'-04'\(bu\h'+03'\c
1100
.\" myisamchk: unpack option.\" unpack option: myisamchk\fB\-\-unpack\fR,
1103
Unpack a table that was packed with
1106
.SH "OTHER MYISAMCHK OPTIONS"
1109
supports the following options for actions other than table checks and repairs:
1113
\h'-04'\(bu\h'+03'\c
1119
.\" myisamchk: analyze option.\" analyze option: myisamchk\fB\-\-analyze\fR,
1122
Analyze the distribution of key values\&. This improves join performance by enabling the join optimizer to better choose the order in which to join the tables and which indexes it should use\&. To obtain information about the key distribution, use a
1123
\fBmyisamchk \-\-description \-\-verbose \fR\fB\fItbl_name\fR\fR
1125
SHOW INDEX FROM \fItbl_name\fR
1131
\h'-04'\(bu\h'+03'\c
1137
.\" myisamchk: block-search option.\" block-search option: myisamchk\fB\-\-block\-search=\fR\fB\fIoffset\fR\fR,
1138
\fB\-b \fR\fB\fIoffset\fR\fR
1140
Find the record that a block at the given offset belongs to\&.
1145
\h'-04'\(bu\h'+03'\c
1151
.\" myisamchk: description option.\" description option: myisamchk\fB\-\-description\fR,
1154
Print some descriptive information about the table\&. Specifying the
1156
option once or twice produces additional information\&. See
1157
the section called \(lqOBTAINING TABLE INFORMATION WITH MYISAMCHK\(rq\&.
1162
\h'-04'\(bu\h'+03'\c
1168
.\" myisamchk: set-auto-increment[ option.\" set-auto-increment[ option: myisamchk\fB\-\-set\-auto\-increment[=\fR\fB\fIvalue\fR\fR\fB]\fR,
1169
\fB\-A[\fR\fB\fIvalue\fR\fR\fB]\fR
1173
numbering for new records to start at the given value (or higher, if there are existing records with
1175
values this large)\&. If
1179
numbers for new records begin with the largest value currently in the table, plus one\&.
1184
\h'-04'\(bu\h'+03'\c
1190
.\" myisamchk: sort-index option.\" sort-index option: myisamchk\fB\-\-sort\-index\fR,
1193
Sort the index tree blocks in high\-low order\&. This optimizes seeks and makes table scans that use indexes faster\&.
1198
\h'-04'\(bu\h'+03'\c
1204
.\" myisamchk: sort-records option.\" sort-records option: myisamchk\fB\-\-sort\-records=\fR\fB\fIN\fR\fR,
1205
\fB\-R \fR\fB\fIN\fR\fR
1207
Sort records according to a particular index\&. This makes your data much more localized and may speed up range\-based
1211
operations that use this index\&. (The first time you use this option to sort a table, it may be very slow\&.) To determine a table\*(Aqs index numbers, use
1212
SHOW INDEX, which displays a table\*(Aqs indexes in the same order that
1214
sees them\&. Indexes are numbered beginning with 1\&.
1216
If keys are not packed (PACK_KEYS=0), they have the same length, so when
1218
sorts and moves records, it just overwrites record offsets in the index\&. If keys are packed (PACK_KEYS=1),
1220
must unpack key blocks first, then re\-create indexes and pack the key blocks again\&. (In this case, re\-creating indexes is faster than updating offsets for each index\&.)
1222
.SH "OBTAINING TABLE INFORMATION WITH MYISAMCHK"
1223
.\" table description: myisamchk
1224
.\" tables: information
1225
.\" examples: myisamchk output
1226
.\" myisamchk: example output
1228
To obtain a description of a
1230
table or statistics about it, use the commands shown here\&. The output from these commands is explained later in this section\&.
1234
\h'-04'\(bu\h'+03'\c
1240
\fBmyisamchk \-d \fR\fB\fItbl_name\fR\fR
1245
\(lqdescribe mode\(rq
1246
to produce a description of your table\&. If you start the MySQL server with external locking disabled,
1248
may report an error for a table that is updated while it runs\&. However, because
1250
does not change the table in describe mode, there is no risk of destroying data\&.
1255
\h'-04'\(bu\h'+03'\c
1261
\fBmyisamchk \-dv \fR\fB\fItbl_name\fR\fR
1267
in verbose mode so that it produces more information about the table\&. Adding
1269
a second time produces even more information\&.
1274
\h'-04'\(bu\h'+03'\c
1280
\fBmyisamchk \-eis \fR\fB\fItbl_name\fR\fR
1282
Shows only the most important information from a table\&. This operation is slow because it must read the entire table\&.
1287
\h'-04'\(bu\h'+03'\c
1293
\fBmyisamchk \-eiv \fR\fB\fItbl_name\fR\fR
1296
\fB\-eis\fR, but tells you what is being done\&.
1301
argument can be either the name of a
1303
table or the name of its index file, as described in
1304
\fBmyisamchk\fR(1)\&. Multiple
1306
arguments can be given\&.
1308
Suppose that a table named
1310
has the following structure\&. (The
1312
table option is included so that in the example output from
1314
shown later, some values are smaller and fit the output format more easily\&.)
1322
id INT NOT NULL AUTO_INCREMENT,
1323
last_name VARCHAR(20) NOT NULL,
1324
first_name VARCHAR(20) NOT NULL,
1328
INDEX (last_name, first_name),
1330
) MAX_ROWS = 1000000;
1336
Suppose also that the table has these data and index file sizes:
1342
\-rw\-rw\-\-\-\- 1 mysql mysql 9347072 Aug 19 11:47 person\&.MYD
1343
\-rw\-rw\-\-\-\- 1 mysql mysql 6066176 Aug 19 11:47 person\&.MYI
1350
\fBmyisamchk \-dvv\fR
1358
Record format: Packed
1359
Character set: latin1_swedish_ci (8)
1361
Creation time: 2009\-08\-19 16:47:41
1362
Recover time: 2009\-08\-19 16:47:56
1363
Status: checked,analyzed,optimized keys
1364
Auto increment key: 1 Last value: 306688
1365
Data records: 306688 Deleted blocks: 0
1366
Datafile parts: 306688 Deleted data: 0
1367
Datafile pointer (bytes): 4 Keyfile pointer (bytes): 3
1368
Datafile length: 9347072 Keyfile length: 6066176
1369
Max datafile length: 4294967294 Max keyfile length: 17179868159
1372
Key Start Len Index Type Rec/key Root Blocksize
1373
1 2 4 unique long 1 99328 1024
1374
2 6 20 multip\&. varchar prefix 512 3563520 1024
1376
3 48 3 multip\&. uint24 NULL 306688 6065152 1024
1377
Field Start Length Nullpos Nullbit Type
1389
Explanations for the types of information
1391
produces are given here\&.
1393
refers to the index file\&.
1397
are synonymous, as are
1402
The initial part of the table description contains these values:
1406
\h'-04'\(bu\h'+03'\c
1421
\h'-04'\(bu\h'+03'\c
1429
The format used to store table rows\&. The preceding examples use
1430
Fixed length\&. Other possible values are
1442
\h'-04'\(bu\h'+03'\c
1450
The table default character set\&.
1455
\h'-04'\(bu\h'+03'\c
1465
format\&. Currently always 1\&.
1470
\h'-04'\(bu\h'+03'\c
1478
When the data file was created\&.
1483
\h'-04'\(bu\h'+03'\c
1491
When the index/data file was last reconstructed\&.
1496
\h'-04'\(bu\h'+03'\c
1504
Table status flags\&. Possible values are
1510
sorted index pages\&.
1515
\h'-04'\(bu\h'+03'\c
1524
The key number associated the table\*(Aqs
1526
column, and the most recently generated value for this column\&. These fields do not appear if there is no such column\&.
1531
\h'-04'\(bu\h'+03'\c
1539
The number of rows in the table\&.
1544
\h'-04'\(bu\h'+03'\c
1552
How many deleted blocks still have reserved space\&. You can optimize your table to minimize this space\&. See
1553
Section\ \&7.6.4, \(lqMyISAM Table Optimization\(rq\&.
1558
\h'-04'\(bu\h'+03'\c
1566
For dynamic\-row format, this indicates how many data blocks there are\&. For an optimized table without fragmented rows, this is the same as
1572
\h'-04'\(bu\h'+03'\c
1580
How many bytes of unreclaimed deleted data there are\&. You can optimize your table to minimize this space\&. See
1581
Section\ \&7.6.4, \(lqMyISAM Table Optimization\(rq\&.
1586
\h'-04'\(bu\h'+03'\c
1594
The size of the data file pointer, in bytes\&. It is usually 2, 3, 4, or 5 bytes\&. Most tables manage with 2 bytes, but this cannot be controlled from MySQL yet\&. For fixed tables, this is a row address\&. For dynamic tables, this is a byte address\&.
1599
\h'-04'\(bu\h'+03'\c
1607
The size of the index file pointer, in bytes\&. It is usually 1, 2, or 3 bytes\&. Most tables manage with 2 bytes, but this is calculated automatically by MySQL\&. It is always a block address\&.
1612
\h'-04'\(bu\h'+03'\c
1620
How long the table data file can become, in bytes\&.
1625
\h'-04'\(bu\h'+03'\c
1633
How long the table index file can become, in bytes\&.
1638
\h'-04'\(bu\h'+03'\c
1646
How much space each row takes, in bytes\&.
1651
part of the output includes a list of all keys in the table\&. For each key,
1653
displays some low\-level information:
1657
\h'-04'\(bu\h'+03'\c
1665
This key\*(Aqs number\&. This value is shown only for the first column of the key\&. If this value is missing, the line corresponds to the second or later column of a multiple\-column key\&. For the table shown in the example, there are two
1667
lines for the second index\&. This indicates that it is a multiple\-part index with two parts\&.
1672
\h'-04'\(bu\h'+03'\c
1680
Where in the row this portion of the index starts\&.
1685
\h'-04'\(bu\h'+03'\c
1693
How long this portion of the index is\&. For packed numbers, this should always be the full length of the column\&. For strings, it may be shorter than the full length of the indexed column, because you can index a prefix of a string column\&. The total length of a multiple\-part key is the sum of the
1695
values for all key parts\&.
1700
\h'-04'\(bu\h'+03'\c
1708
Whether a key value can exist multiple times in the index\&. Possible values are
1717
\h'-04'\(bu\h'+03'\c
1725
What data type this portion of the index has\&. This is a
1727
data type with the possible values
1735
\h'-04'\(bu\h'+03'\c
1743
Address of the root index block\&.
1748
\h'-04'\(bu\h'+03'\c
1756
The size of each index block\&. By default this is 1024, but the value may be changed at compile time when MySQL is built from source\&.
1761
\h'-04'\(bu\h'+03'\c
1769
This is a statistical value used by the optimizer\&. It tells how many rows there are per value for this index\&. A unique index always has a value of 1\&. This may be updated after a table is loaded (or greatly changed) with
1770
\fBmyisamchk \-a\fR\&. If this is not updated at all, a default value of 30 is given\&.
1773
The last part of the output provides information about each column:
1777
\h'-04'\(bu\h'+03'\c
1785
The column number\&.
1790
\h'-04'\(bu\h'+03'\c
1798
The byte position of the column within table rows\&.
1803
\h'-04'\(bu\h'+03'\c
1811
The length of the column in bytes\&.
1816
\h'-04'\(bu\h'+03'\c
1825
For columns that can be
1830
values as a flag in a byte\&. Depending on how many nullable columns there are, there can be one or more bytes used for this purpose\&. The
1834
values, if nonempty, indicate which byte and bit contains that flag indicating whether the column is
1837
The position and number of bytes used to store
1839
flags is shown in the line for field 1\&. This is why there are six
1843
table even though it has only five columns\&.
1848
\h'-04'\(bu\h'+03'\c
1856
The data type\&. The value may contain any of the following descriptors:
1860
\h'-04'\(bu\h'+03'\c
1868
All rows have the same value\&.
1873
\h'-04'\(bu\h'+03'\c
1881
Do not store endspace\&.
1886
\h'-04'\(bu\h'+03'\c
1892
no endspace, not_always
1894
Do not store endspace and do not do endspace compression for all values\&.
1899
\h'-04'\(bu\h'+03'\c
1905
no endspace, no empty
1907
Do not store endspace\&. Do not store empty values\&.
1912
\h'-04'\(bu\h'+03'\c
1920
The column was converted to an
1926
\h'-04'\(bu\h'+03'\c
1934
The most significant
1936
bytes in the value are always 0 and are not stored\&.
1941
\h'-04'\(bu\h'+03'\c
1949
Do not store zeros\&.
1954
\h'-04'\(bu\h'+03'\c
1962
Zero values are stored using one bit\&.
1968
\h'-04'\(bu\h'+03'\c
1976
The number of the Huffman tree associated with the column\&.
1981
\h'-04'\(bu\h'+03'\c
1989
The number of bits used in the Huffman tree\&.
1996
fields are displayed if the table has been compressed with
1997
\fBmyisampack\fR\&. See
1998
\fBmyisampack\fR(1), for an example of this information\&.
2001
\fBmyisamchk \-eiv\fR
2008
Checking MyISAM file: person
2009
Data records: 306688 Deleted blocks: 0
2011
\- check record delete\-chain
2013
\- check key delete\-chain
2015
\- check index reference
2016
\- check data record references index: 1
2017
Key: 1: Keyblocks used: 98% Packed: 0% Max levels: 3
2018
\- check data record references index: 2
2019
Key: 2: Keyblocks used: 99% Packed: 97% Max levels: 3
2020
\- check data record references index: 3
2021
Key: 3: Keyblocks used: 98% Packed: \-14% Max levels: 3
2022
Total: Keyblocks used: 98% Packed: 89%
2023
\- check records and index references
2024
\fI*** LOTS OF ROW NUMBERS DELETED ***\fR
2025
Records: 306688 M\&.recordlength: 25 Packed: 83%
2026
Recordspace used: 97% Empty space: 2% Blocks/Record: 1\&.00
2027
Record blocks: 306688 Delete blocks: 0
2028
Record data: 7934464 Deleted data: 0
2029
Lost space: 256512 Linkdata: 1156096
2030
User time 43\&.08, System time 1\&.68
2031
Maximum resident set size 0, Integral resident set size 0
2032
Non\-physical pagefaults 0, Physical pagefaults 0, Swaps 0
2033
Blocks in 0 out 7, Messages in 0 out 0, Signals 0
2034
Voluntary context switches 0, Involuntary context switches 0
2035
Maximum memory usage: 1046926 bytes (1023k)
2041
\fBmyisamchk \-eiv\fR
2042
output includes the following information:
2046
\h'-04'\(bu\h'+03'\c
2054
The number of rows in the table\&.
2059
\h'-04'\(bu\h'+03'\c
2067
How many deleted blocks still have reserved space\&. You can optimize your table to minimize this space\&. See
2068
Section\ \&7.6.4, \(lqMyISAM Table Optimization\(rq\&.
2073
\h'-04'\(bu\h'+03'\c
2086
\h'-04'\(bu\h'+03'\c
2094
What percentage of the keyblocks are used\&. When a table has just been reorganized with
2095
\fBmyisamchk\fR, the values are very high (very near theoretical maximum)\&.
2100
\h'-04'\(bu\h'+03'\c
2108
MySQL tries to pack key values that have a common suffix\&. This can only be used for indexes on
2112
columns\&. For long indexed strings that have similar leftmost parts, this can significantly reduce the space used\&. In the preceding example, the second key is 40 bytes long and a 97% reduction in space is achieved\&.
2117
\h'-04'\(bu\h'+03'\c
2125
How deep the B\-tree for this key is\&. Large tables with long key values get high values\&.
2130
\h'-04'\(bu\h'+03'\c
2138
How many rows are in the table\&.
2143
\h'-04'\(bu\h'+03'\c
2151
The average row length\&. This is the exact row length for tables with fixed\-length rows, because all rows have the same length\&.
2156
\h'-04'\(bu\h'+03'\c
2164
MySQL strips spaces from the end of strings\&. The
2166
value indicates the percentage of savings achieved by doing this\&.
2171
\h'-04'\(bu\h'+03'\c
2179
What percentage of the data file is used\&.
2184
\h'-04'\(bu\h'+03'\c
2192
What percentage of the data file is unused\&.
2197
\h'-04'\(bu\h'+03'\c
2205
Average number of blocks per row (that is, how many links a fragmented row is composed of)\&. This is always 1\&.0 for fixed\-format tables\&. This value should stay as close to 1\&.0 as possible\&. If it gets too large, you can reorganize the table\&. See
2206
Section\ \&7.6.4, \(lqMyISAM Table Optimization\(rq\&.
2211
\h'-04'\(bu\h'+03'\c
2219
How many blocks (links) are used\&. For fixed\-format tables, this is the same as the number of rows\&.
2224
\h'-04'\(bu\h'+03'\c
2232
How many blocks (links) are deleted\&.
2237
\h'-04'\(bu\h'+03'\c
2245
How many bytes in the data file are used\&.
2250
\h'-04'\(bu\h'+03'\c
2258
How many bytes in the data file are deleted (unused)\&.
2263
\h'-04'\(bu\h'+03'\c
2271
If a row is updated to a shorter length, some space is lost\&. This is the sum of all such losses, in bytes\&.
2276
\h'-04'\(bu\h'+03'\c
2284
When the dynamic table format is used, row fragments are linked with pointers (4 to 7 bytes each)\&.
2286
is the sum of the amount of storage used by all such pointers\&.
2288
.SH "MYISAMCHK MEMORY USAGE"
2289
.\" memory usage: myisamchk
2291
Memory allocation is important when you run
2294
uses no more memory than its memory\-related variables are set to\&. If you are going to use
2296
on very large tables, you should first decide how much memory you want it to use\&. The default is to use only about 3MB to perform repairs\&. By using larger values, you can get
2298
to operate faster\&. For example, if you have more than 512MB RAM available, you could use options such as these (in addition to any other options you might specify):
2304
shell> \fBmyisamchk \-\-myisam_sort_buffer_size=256M \e\fR
2305
\fB\-\-key_buffer_size=512M \e\fR
2306
\fB\-\-read_buffer_size=64M \e\fR
2307
\fB\-\-write_buffer_size=64M \&.\&.\&.\fR
2314
\fB\-\-myisam_sort_buffer_size=16M\fR
2315
is probably enough for most cases\&.
2319
uses temporary files in
2322
points to a memory file system, out of memory errors can easily occur\&. If this happens, run
2325
\fB\-\-tmpdir=\fR\fB\fIpath\fR\fR
2326
option to specify a directory located on a file system that has more space\&.
2328
When performing repair operations,
2330
also needs a lot of disk space:
2334
\h'-04'\(bu\h'+03'\c
2340
Twice the size of the data file (the original file and a copy)\&. This space is not needed if you do a repair with
2341
\fB\-\-quick\fR; in this case, only the index file is re\-created\&.
2342
\fIThis space must be available on the same file system as the original data file\fR, as the copy is created in the same directory as the original\&.
2347
\h'-04'\(bu\h'+03'\c
2353
Space for the new index file that replaces the old one\&. The old index file is truncated at the start of the repair operation, so you usually ignore this space\&. This space must be available on the same file system as the original data file\&.
2358
\h'-04'\(bu\h'+03'\c
2367
\fB\-\-sort\-recover\fR
2369
\fB\-\-safe\-recover\fR), you need space on disk for sorting\&. This space is allocated in the temporary directory (specified by
2372
\fB\-\-tmpdir=\fR\fB\fIpath\fR\fR)\&. The following formula yields the amount of space required:
2378
(\fIlargest_key\fR + \fIrow_pointer_length\fR) * \fInumber_of_rows\fR * 2
2384
You can check the length of the keys and the
2385
\fIrow_pointer_length\fR
2387
\fBmyisamchk \-dv \fR\fB\fItbl_name\fR\fR
2389
the section called \(lqOBTAINING TABLE INFORMATION WITH MYISAMCHK\(rq)\&. The
2390
\fIrow_pointer_length\fR
2392
\fInumber_of_rows\fR
2397
values in the table description\&. To determine the
2401
lines in the table description\&. The
2403
column indicates the number of bytes for each key part\&. For a multiple\-column index, the key size is the sum of the
2405
values for all key parts\&.
2408
If you have a problem with disk space during repair, you can try
2409
\fB\-\-safe\-recover\fR
2411
\fB\-\-recover\fR\&.
2415
Copyright \(co 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2417
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
2419
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
2421
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
2424
For more information, please refer to the MySQL Reference Manual,
2425
which may already be installed locally and which is also available
2426
online at http://dev.mysql.com/doc/.
2428
Oracle Corporation (http://dev.mysql.com/).