1MYISAMCHK(1)                 MySQL Database System                MYISAMCHK(1)
2
3
4

NAME

6       myisamchk - MyISAM table-maintenance utility
7

SYNOPSIS

9       myisamchk [options] tbl_name ...
10

DESCRIPTION

12       The myisamchk utility gets information about your database tables or
13       checks, repairs, or optimizes them.  myisamchk works with MyISAM tables
14       (tables that have .MYD and .MYI files for storing data and indexes).
15
16       You can also use the CHECK TABLE and REPAIR TABLE statements to check
17       and repair MyISAM tables. See Section 13.7.2.3, “CHECK TABLE Syntax”,
18       and Section 13.7.2.6, “REPAIR TABLE Syntax”.
19
20       The use of myisamchk with partitioned tables is not supported.
21
22           Caution
23           It is best to make a backup of a table before performing a table
24           repair operation; under some circumstances the operation might
25           cause data loss. Possible causes include but are not limited to
26           file system errors.
27
28       Invoke myisamchk like this:
29
30           shell> myisamchk [options] tbl_name ...
31
32       The options specify what you want myisamchk to do. They are described
33       in the following sections. You can also get a list of options by
34       invoking myisamchk --help.
35
36       With no options, myisamchk simply checks your table as the default
37       operation. To get more information or to tell myisamchk to take
38       corrective action, specify options as described in the following
39       discussion.
40
41       tbl_name is the database table you want to check or repair. If you run
42       myisamchk somewhere other than in the database directory, you must
43       specify the path to the database directory, because myisamchk has no
44       idea where the database is located. In fact, myisamchk does not
45       actually care whether the files you are working on are located in a
46       database directory. You can copy the files that correspond to a
47       database table into some other location and perform recovery operations
48       on them there.
49
50       You can name several tables on the myisamchk command line if you wish.
51       You can also specify a table by naming its index file (the file with
52       the .MYI suffix). This enables you to specify all tables in a directory
53       by using the pattern *.MYI. For example, if you are in a database
54       directory, you can check all the MyISAM tables in that directory like
55       this:
56
57           shell> myisamchk *.MYI
58
59       If you are not in the database directory, you can check all the tables
60       there by specifying the path to the directory:
61
62           shell> myisamchk /path/to/database_dir/*.MYI
63
64       You can even check all tables in all databases by specifying a wildcard
65       with the path to the MySQL data directory:
66
67           shell> myisamchk /path/to/datadir/*/*.MYI
68
69       The recommended way to quickly check all MyISAM tables is:
70
71           shell> myisamchk --silent --fast /path/to/datadir/*/*.MYI
72
73       If you want to check all MyISAM tables and repair any that are
74       corrupted, you can use the following command:
75
76           shell> myisamchk --silent --force --fast --update-state \
77                     --key_buffer_size=64M --myisam_sort_buffer_size=64M \
78                     --read_buffer_size=1M --write_buffer_size=1M \
79                     /path/to/datadir/*/*.MYI
80
81       This command assumes that you have more than 64MB free. For more
82       information about memory allocation with myisamchk, see the section
83       called “MYISAMCHK MEMORY USAGE”.
84
85       For additional information about using myisamchk, see Section 7.6,
86       “MyISAM Table Maintenance and Crash Recovery”.
87
88           Important
89           You must ensure that no other program is using the tables while you
90           are running myisamchk. The most effective means of doing so is to
91           shut down the MySQL server while running myisamchk, or to lock all
92           tables that myisamchk is being used on.
93
94           Otherwise, when you run myisamchk, it may display the following
95           error message:
96
97               warning: clients are using or haven't closed the table properly
98
99           This means that you are trying to check a table that has been
100           updated by another program (such as the mysqld server) that hasn't
101           yet closed the file or that has died without closing the file
102           properly, which can sometimes lead to the corruption of one or more
103           MyISAM tables.
104
105           If mysqld is running, you must force it to flush any table
106           modifications that are still buffered in memory by using FLUSH
107           TABLES. You should then ensure that no one is using the tables
108           while you are running myisamchk
109
110           However, the easiest way to avoid this problem is to use CHECK
111           TABLE instead of myisamchk to check tables. See Section 13.7.2.3,
112           “CHECK TABLE Syntax”.
113
114       myisamchk supports the following options, which can be specified on the
115       command line or in the [myisamchk] group of an option file.  myisamchk
116       also supports the options for processing option files described at
117       Section 4.2.3.4, “Command-Line Options that Affect Option-File
118       Handling”.
119

MYISAMCHK GENERAL OPTIONS

121       The options described in this section can be used for any type of table
122       maintenance operation performed by myisamchk. The sections following
123       this one describe options that pertain only to specific operations,
124       such as table checking or repairing.
125
126       ·   --help, -?
127
128           Display a help message and exit. Options are grouped by type of
129           operation.
130
131       ·   --HELP, -H
132
133           Display a help message and exit. Options are presented in a single
134           list.
135
136       ·   --debug=debug_options, -# debug_options
137
138           Write a debugging log. A typical debug_options string is
139           'd:t:o,file_name'. The default is 'd:t:o,/tmp/myisamchk.trace'.
140
141       ·   --silent, -s
142
143           Silent mode. Write output only when errors occur. You can use -s
144           twice (-ss) to make myisamchk very silent.
145
146       ·   --verbose, -v
147
148           Verbose mode. Print more information about what the program does.
149           This can be used with -d and -e. Use -v multiple times (-vv, -vvv)
150           for even more output.
151
152       ·   --version, -V
153
154           Display version information and exit.
155
156       ·   --wait, -w
157
158           Instead of terminating with an error if the table is locked, wait
159           until the table is unlocked before continuing. If you are running
160           mysqld with external locking disabled, the table can be locked only
161           by another myisamchk command.
162
163       You can also set the following variables by using --var_name=value
164       syntax:
165
166       ┌───────────────────────┬───────────────────┐
167Variable               Default Value     
168       ├───────────────────────┼───────────────────┤
169       │decode_bits            │ 9                 │
170       ├───────────────────────┼───────────────────┤
171       │ft_max_word_len        │ version-dependent │
172       ├───────────────────────┼───────────────────┤
173       │ft_min_word_len        │ 4                 │
174       ├───────────────────────┼───────────────────┤
175       │ft_stopword_file       │ built-in list     │
176       ├───────────────────────┼───────────────────┤
177       │key_buffer_size        │ 523264            │
178       ├───────────────────────┼───────────────────┤
179       │myisam_block_size      │ 1024              │
180       ├───────────────────────┼───────────────────┤
181       │myisam_sort_key_blocks │ 16                │
182       ├───────────────────────┼───────────────────┤
183       │read_buffer_size       │ 262136            │
184       ├───────────────────────┼───────────────────┤
185       │sort_buffer_size       │ 2097144           │
186       ├───────────────────────┼───────────────────┤
187       │sort_key_blocks        │ 16                │
188       ├───────────────────────┼───────────────────┤
189       │stats_method           │ nulls_unequal     │
190       ├───────────────────────┼───────────────────┤
191       │write_buffer_size      │ 262136            │
192       └───────────────────────┴───────────────────┘
193
194       The possible myisamchk variables and their default values can be
195       examined with myisamchk --help:
196
197       sort_buffer_size is used when the keys are repaired by sorting keys,
198       which is the normal case when you use --recover. As of MySQL 5.1.67,
199       myisam_sort_buffer_size is available as an alternative name to
200       sort_buffer_size.  myisam_sort_buffer_size is preferable to
201       sort_buffer_size because its name corresponds to the
202       myisam_sort_buffer_size server system variable that has a similar
203       meaning.  sort_buffer_size should be considered deprecated.
204
205       key_buffer_size is used when you are checking the table with
206       --extend-check or when the keys are repaired by inserting keys row by
207       row into the table (like when doing normal inserts). Repairing through
208       the key buffer is used in the following cases:
209
210       ·   You use --safe-recover.
211
212       ·   The temporary files needed to sort the keys would be more than
213           twice as big as when creating the key file directly. This is often
214           the case when you have large key values for CHAR, VARCHAR, or TEXT
215           columns, because the sort operation needs to store the complete key
216           values as it proceeds. If you have lots of temporary space and you
217           can force myisamchk to repair by sorting, you can use the
218           --sort-recover option.
219
220       Repairing through the key buffer takes much less disk space than using
221       sorting, but is also much slower.
222
223       If you want a faster repair, set the key_buffer_size and
224       myisam_sort_buffer_size variables to about 25% of your available
225       memory. You can set both variables to large values, because only one of
226       them is used at a time.
227
228       myisam_block_size is the size used for index blocks.
229
230       stats_method influences how NULL values are treated for index
231       statistics collection when the --analyze option is given. It acts like
232       the myisam_stats_method system variable. For more information, see the
233       description of myisam_stats_method in Section 5.1.4, “Server System
234       Variables”, and Section 8.5.4, “InnoDB and MyISAM Index Statistics
235       Collection”.
236
237       ft_min_word_len and ft_max_word_len indicate the minimum and maximum
238       word length for FULLTEXT indexes.  ft_stopword_file names the stopword
239       file. These need to be set under the following circumstances.
240
241       If you use myisamchk to perform an operation that modifies table
242       indexes (such as repair or analyze), the FULLTEXT indexes are rebuilt
243       using the default full-text parameter values for minimum and maximum
244       word length and the stopword file unless you specify otherwise. This
245       can result in queries failing.
246
247       The problem occurs because these parameters are known only by the
248       server. They are not stored in MyISAM index files. To avoid the problem
249       if you have modified the minimum or maximum word length or the stopword
250       file in the server, specify the same ft_min_word_len, ft_max_word_len,
251       and ft_stopword_file values to myisamchk that you use for mysqld. For
252       example, if you have set the minimum word length to 3, you can repair a
253       table with myisamchk like this:
254
255           shell> myisamchk --recover --ft_min_word_len=3 tbl_name.MYI
256
257       To ensure that myisamchk and the server use the same values for
258       full-text parameters, you can place each one in both the [mysqld] and
259       [myisamchk] sections of an option file:
260
261           [mysqld]
262           ft_min_word_len=3
263           [myisamchk]
264           ft_min_word_len=3
265
266       An alternative to using myisamchk is to use the REPAIR TABLE, ANALYZE
267       TABLE, OPTIMIZE TABLE, or ALTER TABLE. These statements are performed
268       by the server, which knows the proper full-text parameter values to
269       use.
270

MYISAMCHK CHECK OPTIONS

272       myisamchk supports the following options for table checking operations:
273
274       ·   --check, -c
275
276           Check the table for errors. This is the default operation if you
277           specify no option that selects an operation type explicitly.
278
279       ·   --check-only-changed, -C
280
281           Check only tables that have changed since the last check.
282
283       ·   --extend-check, -e
284
285           Check the table very thoroughly. This is quite slow if the table
286           has many indexes. This option should only be used in extreme cases.
287           Normally, myisamchk or myisamchk --medium-check should be able to
288           determine whether there are any errors in the table.
289
290           If you are using --extend-check and have plenty of memory, setting
291           the key_buffer_size variable to a large value helps the repair
292           operation run faster.
293
294           See also the description of this option under table repair options.
295
296           For a description of the output format, see the section called
297           “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
298
299       ·   --fast, -F
300
301           Check only tables that haven't been closed properly.
302
303       ·   --force, -f
304
305           Do a repair operation automatically if myisamchk finds any errors
306           in the table. The repair type is the same as that specified with
307           the --recover or -r option.
308
309       ·   --information, -i
310
311           Print informational statistics about the table that is checked.
312
313       ·   --medium-check, -m
314
315           Do a check that is faster than an --extend-check operation. This
316           finds only 99.99% of all errors, which should be good enough in
317           most cases.
318
319       ·   --read-only, -T
320
321           Do not mark the table as checked. This is useful if you use
322           myisamchk to check a table that is in use by some other application
323           that does not use locking, such as mysqld when run with external
324           locking disabled.
325
326       ·   --update-state, -U
327
328           Store information in the .MYI file to indicate when the table was
329           checked and whether the table crashed. This should be used to get
330           full benefit of the --check-only-changed option, but you shouldn't
331           use this option if the mysqld server is using the table and you are
332           running it with external locking disabled.
333

MYISAMCHK REPAIR OPTIONS

335       myisamchk supports the following options for table repair operations
336       (operations performed when an option such as --recover or
337       --safe-recover is given):
338
339       ·   --backup, -B
340
341           Make a backup of the .MYD file as file_name-time.BAK
342
343       ·   --character-sets-dir=path
344
345           The directory where character sets are installed. See Section 10.5,
346           “Character Set Configuration”.
347
348       ·   --correct-checksum
349
350           Correct the checksum information for the table.
351
352       ·   --data-file-length=len, -D len
353
354           The maximum length of the data file (when re-creating data file
355           when it is “full”).
356
357       ·   --extend-check, -e
358
359           Do a repair that tries to recover every possible row from the data
360           file. Normally, this also finds a lot of garbage rows. Do not use
361           this option unless you are desperate.
362
363           See also the description of this option under table checking
364           options.
365
366           For a description of the output format, see the section called
367           “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
368
369       ·   --force, -f
370
371           Overwrite old intermediate files (files with names like
372           tbl_name.TMD) instead of aborting.
373
374       ·   --keys-used=val, -k val
375
376           For myisamchk, the option value is a bit-value that indicates which
377           indexes to update. Each binary bit of the option value corresponds
378           to a table index, where the first index is bit 0. An option value
379           of 0 disables updates to all indexes, which can be used to get
380           faster inserts. Deactivated indexes can be reactivated by using
381           myisamchk -r.
382
383       ·   --no-symlinks, -l
384
385           Do not follow symbolic links. Normally myisamchk repairs the table
386           that a symlink points to. This option does not exist as of MySQL
387           4.0 because versions from 4.0 on do not remove symlinks during
388           repair operations.
389
390       ·   --max-record-length=len
391
392           Skip rows larger than the given length if myisamchk cannot allocate
393           memory to hold them.
394
395       ·   --parallel-recover, -p
396
397           Use the same technique as -r and -n, but create all the keys in
398           parallel, using different threads.  This is beta-quality code. Use
399           at your own risk!
400
401       ·   --quick, -q
402
403           Achieve a faster repair by modifying only the index file, not the
404           data file. You can specify this option twice to force myisamchk to
405           modify the original data file in case of duplicate keys.
406
407       ·   --recover, -r
408
409           Do a repair that can fix almost any problem except unique keys that
410           are not unique (which is an extremely unlikely error with MyISAM
411           tables). If you want to recover a table, this is the option to try
412           first. You should try --safe-recover only if myisamchk reports that
413           the table cannot be recovered using --recover. (In the unlikely
414           case that --recover fails, the data file remains intact.)
415
416           If you have lots of memory, you should increase the value of
417           myisam_sort_buffer_size.
418
419       ·   --safe-recover, -o
420
421           Do a repair using an old recovery method that reads through all
422           rows in order and updates all index trees based on the rows found.
423           This is an order of magnitude slower than --recover, but can handle
424           a couple of very unlikely cases that --recover cannot. This
425           recovery method also uses much less disk space than --recover.
426           Normally, you should repair first using --recover, and then with
427           --safe-recover only if --recover fails.
428
429           If you have lots of memory, you should increase the value of
430           key_buffer_size.
431
432       ·   --set-character-set=name
433
434           Change the character set used by the table indexes. This option was
435           replaced by --set-collation in MySQL 5.0.3.
436
437       ·   --set-collation=name
438
439           Specify the collation to use for sorting table indexes. The
440           character set name is implied by the first part of the collation
441           name.
442
443       ·   --sort-recover, -n
444
445           Force myisamchk to use sorting to resolve the keys even if the
446           temporary files would be very large.
447
448       ·   --tmpdir=path, -t path
449
450           The path of the directory to be used for storing temporary files.
451           If this is not set, myisamchk uses the value of the TMPDIR
452           environment variable.  --tmpdir can be set to a list of directory
453           paths that are used successively in round-robin fashion for
454           creating temporary files. The separator character between directory
455           names is the colon (“:”) on Unix and the semicolon (“;”) on
456           Windows, NetWare, and OS/2.
457
458       ·   --unpack, -u
459
460           Unpack a table that was packed with myisampack.
461

OTHER MYISAMCHK OPTIONS

463       myisamchk supports the following options for actions other than table
464       checks and repairs:
465
466       ·   --analyze, -a
467
468           Analyze the distribution of key values. This improves join
469           performance by enabling the join optimizer to better choose the
470           order in which to join the tables and which indexes it should use.
471           To obtain information about the key distribution, use a myisamchk
472           --description --verbose tbl_name command or the SHOW INDEX FROM
473           tbl_name statement.
474
475       ·   --block-search=offset, -b offset
476
477           Find the record that a block at the given offset belongs to.
478
479       ·   --description, -d
480
481           Print some descriptive information about the table. Specifying the
482           --verbose option once or twice produces additional information. See
483           the section called “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
484
485       ·   --set-auto-increment[=value], -A[value]
486
487           Force AUTO_INCREMENT numbering for new records to start at the
488           given value (or higher, if there are existing records with
489           AUTO_INCREMENT values this large). If value is not specified,
490           AUTO_INCREMENT numbers for new records begin with the largest value
491           currently in the table, plus one.
492
493       ·   --sort-index, -S
494
495           Sort the index tree blocks in high-low order. This optimizes seeks
496           and makes table scans that use indexes faster.
497
498       ·   --sort-records=N, -R N
499
500           Sort records according to a particular index. This makes your data
501           much more localized and may speed up range-based SELECT and ORDER
502           BY operations that use this index. (The first time you use this
503           option to sort a table, it may be very slow.) To determine a
504           table's index numbers, use SHOW INDEX, which displays a table's
505           indexes in the same order that myisamchk sees them. Indexes are
506           numbered beginning with 1.
507
508           If keys are not packed (PACK_KEYS=0), they have the same length, so
509           when myisamchk sorts and moves records, it just overwrites record
510           offsets in the index. If keys are packed (PACK_KEYS=1), myisamchk
511           must unpack key blocks first, then re-create indexes and pack the
512           key blocks again. (In this case, re-creating indexes is faster than
513           updating offsets for each index.)
514

OBTAINING TABLE INFORMATION WITH MYISAMCHK

516       To obtain a description of a MyISAM table or statistics about it, use
517       the commands shown here. The output from these commands is explained
518       later in this section.
519
520       ·   myisamchk -d tbl_name
521
522           Runs myisamchk in “describe mode” to produce a description of your
523           table. If you start the MySQL server with external locking
524           disabled, myisamchk may report an error for a table that is updated
525           while it runs. However, because myisamchk does not change the table
526           in describe mode, there is no risk of destroying data.
527
528       ·   myisamchk -dv tbl_name
529
530           Adding -v runs myisamchk in verbose mode so that it produces more
531           information about the table. Adding -v a second time produces even
532           more information.
533
534       ·   myisamchk -eis tbl_name
535
536           Shows only the most important information from a table. This
537           operation is slow because it must read the entire table.
538
539       ·   myisamchk -eiv tbl_name
540
541           This is like -eis, but tells you what is being done.
542
543       The tbl_name argument can be either the name of a MyISAM table or the
544       name of its index file, as described in myisamchk(1). Multiple tbl_name
545       arguments can be given.
546
547       Suppose that a table named person has the following structure. (The
548       MAX_ROWS table option is included so that in the example output from
549       myisamchk shown later, some values are smaller and fit the output
550       format more easily.)
551
552           CREATE TABLE person
553           (
554             id         INT NOT NULL AUTO_INCREMENT,
555             last_name  VARCHAR(20) NOT NULL,
556             first_name VARCHAR(20) NOT NULL,
557             birth      DATE,
558             death      DATE,
559             PRIMARY KEY (id),
560             INDEX (last_name, first_name),
561             INDEX (birth)
562           ) MAX_ROWS = 1000000;
563
564       Suppose also that the table has these data and index file sizes:
565
566           -rw-rw----  1 mysql  mysql  9347072 Aug 19 11:47 person.MYD
567           -rw-rw----  1 mysql  mysql  6066176 Aug 19 11:47 person.MYI
568
569       Example of myisamchk -dvv output:
570
571           MyISAM file:         person
572           Record format:       Packed
573           Character set:       latin1_swedish_ci (8)
574           File-version:        1
575           Creation time:       2009-08-19 16:47:41
576           Recover time:        2009-08-19 16:47:56
577           Status:              checked,analyzed,optimized keys
578           Auto increment key:              1  Last value:                306688
579           Data records:               306688  Deleted blocks:                 0
580           Datafile parts:             306688  Deleted data:                   0
581           Datafile pointer (bytes):        4  Keyfile pointer (bytes):        3
582           Datafile length:           9347072  Keyfile length:           6066176
583           Max datafile length:    4294967294  Max keyfile length:   17179868159
584           Recordlength:                   54
585           table description:
586           Key Start Len Index   Type                 Rec/key         Root  Blocksize
587           1   2     4   unique  long                       1        99328       1024
588           2   6     20  multip. varchar prefix           512      3563520       1024
589               27    20          varchar                  512
590           3   48    3   multip. uint24 NULL           306688      6065152       1024
591           Field Start Length Nullpos Nullbit Type
592           1     1     1
593           2     2     4                      no zeros
594           3     6     21                     varchar
595           4     27    21                     varchar
596           5     48    3      1       1       no zeros
597           6     51    3      1       2       no zeros
598
599       Explanations for the types of information myisamchk produces are given
600       here.  “Keyfile” refers to the index file.  “Record” and “row” are
601       synonymous, as are “field” and “column.”
602
603       The initial part of the table description contains these values:
604
605       ·   MyISAM file
606
607           Name of the MyISAM (index) file.
608
609       ·   Record format
610
611           The format used to store table rows. The preceding examples use
612           Fixed length. Other possible values are Compressed and Packed.
613           (Packed corresponds to what SHOW TABLE STATUS reports as Dynamic.)
614
615       ·   Chararacter set
616
617           The table default character set.
618
619       ·   File-version
620
621           Version of MyISAM format. Currently always 1.
622
623       ·   Creation time
624
625           When the data file was created.
626
627       ·   Recover time
628
629           When the index/data file was last reconstructed.
630
631       ·   Status
632
633           Table status flags. Possible values are crashed, open, changed,
634           analyzed, optimized keys, and sorted index pages.
635
636       ·   Auto increment key, Last value
637
638           The key number associated the table's AUTO_INCREMENT column, and
639           the most recently generated value for this column. These fields do
640           not appear if there is no such column.
641
642       ·   Data records
643
644           The number of rows in the table.
645
646       ·   Deleted blocks
647
648           How many deleted blocks still have reserved space. You can optimize
649           your table to minimize this space. See Section 7.6.4, “MyISAM Table
650           Optimization”.
651
652       ·   Datafile parts
653
654           For dynamic-row format, this indicates how many data blocks there
655           are. For an optimized table without fragmented rows, this is the
656           same as Data records.
657
658       ·   Deleted data
659
660           How many bytes of unreclaimed deleted data there are. You can
661           optimize your table to minimize this space. See Section 7.6.4,
662           “MyISAM Table Optimization”.
663
664       ·   Datafile pointer
665
666           The size of the data file pointer, in bytes. It is usually 2, 3, 4,
667           or 5 bytes. Most tables manage with 2 bytes, but this cannot be
668           controlled from MySQL yet. For fixed tables, this is a row address.
669           For dynamic tables, this is a byte address.
670
671       ·   Keyfile pointer
672
673           The size of the index file pointer, in bytes. It is usually 1, 2,
674           or 3 bytes. Most tables manage with 2 bytes, but this is calculated
675           automatically by MySQL. It is always a block address.
676
677       ·   Max datafile length
678
679           How long the table data file can become, in bytes.
680
681       ·   Max keyfile length
682
683           How long the table index file can become, in bytes.
684
685       ·   Recordlength
686
687           How much space each row takes, in bytes.
688
689       The table description part of the output includes a list of all keys in
690       the table. For each key, myisamchk displays some low-level information:
691
692       ·   Key
693
694           This key's number. This value is shown only for the first column of
695           the key. If this value is missing, the line corresponds to the
696           second or later column of a multiple-column key. For the table
697           shown in the example, there are two table description lines for the
698           second index. This indicates that it is a multiple-part index with
699           two parts.
700
701       ·   Start
702
703           Where in the row this portion of the index starts.
704
705       ·   Len
706
707           How long this portion of the index is. For packed numbers, this
708           should always be the full length of the column. For strings, it may
709           be shorter than the full length of the indexed column, because you
710           can index a prefix of a string column. The total length of a
711           multiple-part key is the sum of the Len values for all key parts.
712
713       ·   Index
714
715           Whether a key value can exist multiple times in the index. Possible
716           values are unique or multip.  (multiple).
717
718       ·   Type
719
720           What data type this portion of the index has. This is a MyISAM data
721           type with the possible values packed, stripped, or empty.
722
723       ·   Root
724
725           Address of the root index block.
726
727       ·   Blocksize
728
729           The size of each index block. By default this is 1024, but the
730           value may be changed at compile time when MySQL is built from
731           source.
732
733       ·   Rec/key
734
735           This is a statistical value used by the optimizer. It tells how
736           many rows there are per value for this index. A unique index always
737           has a value of 1. This may be updated after a table is loaded (or
738           greatly changed) with myisamchk -a. If this is not updated at all,
739           a default value of 30 is given.
740
741       The last part of the output provides information about each column:
742
743       ·   Field
744
745           The column number.
746
747       ·   Start
748
749           The byte position of the column within table rows.
750
751       ·   Length
752
753           The length of the column in bytes.
754
755       ·   Nullpos, Nullbit
756
757           For columns that can be NULL, MyISAM stores NULL values as a flag
758           in a byte. Depending on how many nullable columns there are, there
759           can be one or more bytes used for this purpose. The Nullpos and
760           Nullbit values, if nonempty, indicate which byte and bit contains
761           that flag indicating whether the column is NULL.
762
763           The position and number of bytes used to store NULL flags is shown
764           in the line for field 1. This is why there are six Field lines for
765           the person table even though it has only five columns.
766
767       ·   Type
768
769           The data type. The value may contain any of the following
770           descriptors:
771
772           ·   constant
773
774               All rows have the same value.
775
776           ·   no endspace
777
778               Do not store endspace.
779
780           ·   no endspace, not_always
781
782               Do not store endspace and do not do endspace compression for
783               all values.
784
785           ·   no endspace, no empty
786
787               Do not store endspace. Do not store empty values.
788
789           ·   table-lookup
790
791               The column was converted to an ENUM.
792
793           ·   zerofill(N)
794
795               The most significant N bytes in the value are always 0 and are
796               not stored.
797
798           ·   no zeros
799
800               Do not store zeros.
801
802           ·   always zero
803
804               Zero values are stored using one bit.
805
806       ·   Huff tree
807
808           The number of the Huffman tree associated with the column.
809
810       ·   Bits
811
812           The number of bits used in the Huffman tree.
813
814       The Huff tree and Bits fields are displayed if the table has been
815       compressed with myisampack. See myisampack(1), for an example of this
816       information.
817
818       Example of myisamchk -eiv output:
819
820           Checking MyISAM file: person
821           Data records:  306688   Deleted blocks:       0
822           - check file-size
823           - check record delete-chain
824           No recordlinks
825           - check key delete-chain
826           block_size 1024:
827           - check index reference
828           - check data record references index: 1
829           Key:  1:  Keyblocks used:  98%  Packed:    0%  Max levels:  3
830           - check data record references index: 2
831           Key:  2:  Keyblocks used:  99%  Packed:   97%  Max levels:  3
832           - check data record references index: 3
833           Key:  3:  Keyblocks used:  98%  Packed:  -14%  Max levels:  3
834           Total:    Keyblocks used:  98%  Packed:   89%
835           - check records and index references
836           *** LOTS OF ROW NUMBERS DELETED ***
837           Records:            306688  M.recordlength:       25  Packed:            83%
838           Recordspace used:       97% Empty space:           2% Blocks/Record:   1.00
839           Record blocks:      306688  Delete blocks:         0
840           Record data:       7934464  Deleted data:          0
841           Lost space:         256512  Linkdata:        1156096
842           User time 43.08, System time 1.68
843           Maximum resident set size 0, Integral resident set size 0
844           Non-physical pagefaults 0, Physical pagefaults 0, Swaps 0
845           Blocks in 0 out 7, Messages in 0 out 0, Signals 0
846           Voluntary context switches 0, Involuntary context switches 0
847           Maximum memory usage: 1046926 bytes (1023k)
848
849       myisamchk -eiv output includes the following information:
850
851       ·   Data records
852
853           The number of rows in the table.
854
855       ·   Deleted blocks
856
857           How many deleted blocks still have reserved space. You can optimize
858           your table to minimize this space. See Section 7.6.4, “MyISAM Table
859           Optimization”.
860
861       ·   Key
862
863           The key number.
864
865       ·   Keyblocks used
866
867           What percentage of the keyblocks are used. When a table has just
868           been reorganized with myisamchk, the values are very high (very
869           near theoretical maximum).
870
871       ·   Packed
872
873           MySQL tries to pack key values that have a common suffix. This can
874           only be used for indexes on CHAR and VARCHAR columns. For long
875           indexed strings that have similar leftmost parts, this can
876           significantly reduce the space used. In the preceding example, the
877           second key is 40 bytes long and a 97% reduction in space is
878           achieved.
879
880       ·   Max levels
881
882           How deep the B-tree for this key is. Large tables with long key
883           values get high values.
884
885       ·   Records
886
887           How many rows are in the table.
888
889       ·   M.recordlength
890
891           The average row length. This is the exact row length for tables
892           with fixed-length rows, because all rows have the same length.
893
894       ·   Packed
895
896           MySQL strips spaces from the end of strings. The Packed value
897           indicates the percentage of savings achieved by doing this.
898
899       ·   Recordspace used
900
901           What percentage of the data file is used.
902
903       ·   Empty space
904
905           What percentage of the data file is unused.
906
907       ·   Blocks/Record
908
909           Average number of blocks per row (that is, how many links a
910           fragmented row is composed of). This is always 1.0 for fixed-format
911           tables. This value should stay as close to 1.0 as possible. If it
912           gets too large, you can reorganize the table. See Section 7.6.4,
913           “MyISAM Table Optimization”.
914
915       ·   Recordblocks
916
917           How many blocks (links) are used. For fixed-format tables, this is
918           the same as the number of rows.
919
920       ·   Deleteblocks
921
922           How many blocks (links) are deleted.
923
924       ·   Recorddata
925
926           How many bytes in the data file are used.
927
928       ·   Deleted data
929
930           How many bytes in the data file are deleted (unused).
931
932       ·   Lost space
933
934           If a row is updated to a shorter length, some space is lost. This
935           is the sum of all such losses, in bytes.
936
937       ·   Linkdata
938
939           When the dynamic table format is used, row fragments are linked
940           with pointers (4 to 7 bytes each).  Linkdata is the sum of the
941           amount of storage used by all such pointers.
942

MYISAMCHK MEMORY USAGE

944       Memory allocation is important when you run myisamchk.  myisamchk uses
945       no more memory than its memory-related variables are set to. If you are
946       going to use myisamchk on very large tables, you should first decide
947       how much memory you want it to use. The default is to use only about
948       3MB to perform repairs. By using larger values, you can get myisamchk
949       to operate faster. For example, if you have more than 512MB RAM
950       available, you could use options such as these (in addition to any
951       other options you might specify):
952
953           shell> myisamchk --myisam_sort_buffer_size=256M \
954                      --key_buffer_size=512M \
955                      --read_buffer_size=64M \
956                      --write_buffer_size=64M ...
957
958       Using --myisam_sort_buffer_size=16M is probably enough for most cases.
959
960       Be aware that myisamchk uses temporary files in TMPDIR. If TMPDIR
961       points to a memory file system, out of memory errors can easily occur.
962       If this happens, run myisamchk with the --tmpdir=path option to specify
963       a directory located on a file system that has more space.
964
965       When performing repair operations, myisamchk also needs a lot of disk
966       space:
967
968       ·   Twice the size of the data file (the original file and a copy).
969           This space is not needed if you do a repair with --quick; in this
970           case, only the index file is re-created.  This space must be
971           available on the same file system as the original data file, as the
972           copy is created in the same directory as the original.
973
974       ·   Space for the new index file that replaces the old one. The old
975           index file is truncated at the start of the repair operation, so
976           you usually ignore this space. This space must be available on the
977           same file system as the original data file.
978
979       ·   When using --recover or --sort-recover (but not when using
980           --safe-recover), you need space on disk for sorting. This space is
981           allocated in the temporary directory (specified by TMPDIR or
982           --tmpdir=path). The following formula yields the amount of space
983           required:
984
985               (largest_key + row_pointer_length) * number_of_rows * 2
986
987           You can check the length of the keys and the row_pointer_length
988           with myisamchk -dv tbl_name (see the section called “OBTAINING
989           TABLE INFORMATION WITH MYISAMCHK”). The row_pointer_length and
990           number_of_rows values are the Datafile pointer and Data records
991           values in the table description. To determine the largest_key
992           value, check the Key lines in the table description. The Len column
993           indicates the number of bytes for each key part. For a
994           multiple-column index, the key size is the sum of the Len values
995           for all key parts.
996
997       If you have a problem with disk space during repair, you can try
998       --safe-recover instead of --recover.
999
1001       Copyright © 1997, 2013, Oracle and/or its affiliates. All rights
1002       reserved.
1003
1004       This documentation is free software; you can redistribute it and/or
1005       modify it only under the terms of the GNU General Public License as
1006       published by the Free Software Foundation; version 2 of the License.
1007
1008       This documentation is distributed in the hope that it will be useful,
1009       but WITHOUT ANY WARRANTY; without even the implied warranty of
1010       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1011       General Public License for more details.
1012
1013       You should have received a copy of the GNU General Public License along
1014       with the program; if not, write to the Free Software Foundation, Inc.,
1015       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
1016       http://www.gnu.org/licenses/.
1017
1018

SEE ALSO

1020       For more information, please refer to the MySQL Reference Manual, which
1021       may already be installed locally and which is also available online at
1022       http://dev.mysql.com/doc/.
1023

AUTHOR

1025       Oracle Corporation (http://dev.mysql.com/).
1026
1027
1028
1029MySQL 5.1                         11/04/2013                      MYISAMCHK(1)
Impressum