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

MYISAMCHK GENERAL OPTIONS

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

MYISAMCHK CHECK OPTIONS

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

MYISAMCHK REPAIR OPTIONS

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

OTHER MYISAMCHK OPTIONS

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

MYISAMCHK TABLE INFORMATION

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

MYISAMCHK MEMORY USAGE

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

SEE ALSO

998       For more information, please refer to the MySQL Reference Manual, which
999       may already be installed locally and which is also available online at
1000       http://dev.mysql.com/doc/.
1001

AUTHOR

1003       Sun Microsystems, Inc. (http://www.mysql.com/).
1004
1005
1006
1007MySQL 5.1                         04/06/2010                      MYISAMCHK(1)
Impressum