1MYISAMCHK(1) MySQL Database System MYISAMCHK(1)
2
3
4
6 myisamchk - MyISAM table-maintenance utility
7
9 myisamchk [options] tbl_name ...
10
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 12.4.2.3, “CHECK TABLE Syntax”,
18 and Section 12.4.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 --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 6.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 12.4.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.3.1, “Command-Line Options that Affect Option-File
118 Handling”.
119
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 ┌──────────────────┬───────────────────┐
167 │Variable │ 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 │read_buffer_size │ 262136 │
182 ├──────────────────┼───────────────────┤
183 │sort_buffer_size │ 2097144 │
184 ├──────────────────┼───────────────────┤
185 │sort_key_blocks │ 16 │
186 ├──────────────────┼───────────────────┤
187 │stats_method │ nulls_unequal │
188 ├──────────────────┼───────────────────┤
189 │write_buffer_size │ 262136 │
190 └──────────────────┴───────────────────┘
191
192 The possible myisamchk variables and their default values can be
193 examined with myisamchk --help:
194
195 sort_buffer_size is used when the keys are repaired by sorting keys,
196 which is the normal case when you use --recover.
197
198 key_buffer_size is used when you are checking the table with
199 --extend-check or when the keys are repaired by inserting keys row by
200 row into the table (like when doing normal inserts). Repairing through
201 the key buffer is used in the following cases:
202
203 · You use --safe-recover.
204
205 · The temporary files needed to sort the keys would be more than
206 twice as big as when creating the key file directly. This is often
207 the case when you have large key values for CHAR, VARCHAR, or TEXT
208 columns, because the sort operation needs to store the complete key
209 values as it proceeds. If you have lots of temporary space and you
210 can force myisamchk to repair by sorting, you can use the
211 --sort-recover option.
212
213 Repairing through the key buffer takes much less disk space than using
214 sorting, but is also much slower.
215
216 If you want a faster repair, set the key_buffer_size and
217 sort_buffer_size variables to about 25% of your available memory. You
218 can set both variables to large values, because only one of them is
219 used at a time.
220
221 myisam_block_size is the size used for index blocks.
222
223 stats_method influences how NULL values are treated for index
224 statistics collection when the --analyze option is given. It acts like
225 the myisam_stats_method system variable. For more information, see the
226 description of myisam_stats_method in Section 5.1.3, “Server System
227 Variables”, and Section 7.5.4, “InnoDB and MyISAM Index Statistics
228 Collection”.
229
230 ft_min_word_len and ft_max_word_len indicate the minimum and maximum
231 word length for FULLTEXT indexes. ft_stopword_file names the stopword
232 file. These need to be set under the following circumstances.
233
234 If you use myisamchk to perform an operation that modifies table
235 indexes (such as repair or analyze), the FULLTEXT indexes are rebuilt
236 using the default full-text parameter values for minimum and maximum
237 word length and the stopword file unless you specify otherwise. This
238 can result in queries failing.
239
240 The problem occurs because these parameters are known only by the
241 server. They are not stored in MyISAM index files. To avoid the problem
242 if you have modified the minimum or maximum word length or the stopword
243 file in the server, specify the same ft_min_word_len, ft_max_word_len,
244 and ft_stopword_file values to myisamchk that you use for mysqld. For
245 example, if you have set the minimum word length to 3, you can repair a
246 table with myisamchk like this:
247
248 shell> myisamchk --recover --ft_min_word_len=3 tbl_name.MYI
249
250 To ensure that myisamchk and the server use the same values for
251 full-text parameters, you can place each one in both the [mysqld] and
252 [myisamchk] sections of an option file:
253
254 [mysqld]
255 ft_min_word_len=3
256 [myisamchk]
257 ft_min_word_len=3
258
259 An alternative to using myisamchk is to use the REPAIR TABLE, ANALYZE
260 TABLE, OPTIMIZE TABLE, or ALTER TABLE. These statements are performed
261 by the server, which knows the proper full-text parameter values to
262 use.
263
265 myisamchk supports the following options for table checking operations:
266
267 · --check, -c
268
269 Check the table for errors. This is the default operation if you
270 specify no option that selects an operation type explicitly.
271
272 · --check-only-changed, -C
273
274 Check only tables that have changed since the last check.
275
276 · --extend-check, -e
277
278 Check the table very thoroughly. This is quite slow if the table
279 has many indexes. This option should only be used in extreme cases.
280 Normally, myisamchk or myisamchk --medium-check should be able to
281 determine whether there are any errors in the table.
282
283 If you are using --extend-check and have plenty of memory, setting
284 the key_buffer_size variable to a large value helps the repair
285 operation run faster.
286
287 See also the description of this option under table repair options.
288
289 For a description of the output format, see the section called
290 “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
291
292 · --fast, -F
293
294 Check only tables that haven´t been closed properly.
295
296 · --force, -f
297
298 Do a repair operation automatically if myisamchk finds any errors
299 in the table. The repair type is the same as that specified with
300 the --recover or -r option.
301
302 · --information, -i
303
304 Print informational statistics about the table that is checked.
305
306 · --medium-check, -m
307
308 Do a check that is faster than an --extend-check operation. This
309 finds only 99.99% of all errors, which should be good enough in
310 most cases.
311
312 · --read-only, -T
313
314 Do not mark the table as checked. This is useful if you use
315 myisamchk to check a table that is in use by some other application
316 that does not use locking, such as mysqld when run with external
317 locking disabled.
318
319 · --update-state, -U
320
321 Store information in the .MYI file to indicate when the table was
322 checked and whether the table crashed. This should be used to get
323 full benefit of the --check-only-changed option, but you shouldn´t
324 use this option if the mysqld server is using the table and you are
325 running it with external locking disabled.
326
328 myisamchk supports the following options for table repair operations
329 (operations performed when an option such as --recover or
330 --safe-recover is given):
331
332 · --backup, -B
333
334 Make a backup of the .MYD file as file_name-time.BAK
335
336 · --character-sets-dir=path
337
338 The directory where character sets are installed. See Section 9.5,
339 “Character Set Configuration”.
340
341 · --correct-checksum
342
343 Correct the checksum information for the table.
344
345 · --data-file-length=len, -D len
346
347 The maximum length of the data file (when re-creating data file
348 when it is “full”).
349
350 · --extend-check, -e
351
352 Do a repair that tries to recover every possible row from the data
353 file. Normally, this also finds a lot of garbage rows. Do not use
354 this option unless you are desperate.
355
356 See also the description of this option under table checking
357 options.
358
359 For a description of the output format, see the section called
360 “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
361
362 · --force, -f
363
364 Overwrite old intermediate files (files with names like
365 tbl_name.TMD) instead of aborting.
366
367 · --keys-used=val, -k val
368
369 For myisamchk, the option value is a bit-value that indicates which
370 indexes to update. Each binary bit of the option value corresponds
371 to a table index, where the first index is bit 0. An option value
372 of 0 disables updates to all indexes, which can be used to get
373 faster inserts. Deactivated indexes can be reactivated by using
374 myisamchk -r.
375
376 · --no-symlinks, -l
377
378 Do not follow symbolic links. Normally myisamchk repairs the table
379 that a symlink points to. This option does not exist as of MySQL
380 4.0 because versions from 4.0 on do not remove symlinks during
381 repair operations.
382
383 · --max-record-length=len
384
385 Skip rows larger than the given length if myisamchk cannot allocate
386 memory to hold them.
387
388 · --parallel-recover, -p
389
390 Use the same technique as -r and -n, but create all the keys in
391 parallel, using different threads. This is beta-quality code. Use
392 at your own risk!
393
394 · --quick, -q
395
396 Achieve a faster repair by modifying only the index file, not the
397 data file. You can specify this option twice to force myisamchk to
398 modify the original data file in case of duplicate keys.
399
400 · --recover, -r
401
402 Do a repair that can fix almost any problem except unique keys that
403 are not unique (which is an extremely unlikely error with MyISAM
404 tables). If you want to recover a table, this is the option to try
405 first. You should try --safe-recover only if myisamchk reports that
406 the table cannot be recovered using --recover. (In the unlikely
407 case that --recover fails, the data file remains intact.)
408
409 If you have lots of memory, you should increase the value of
410 sort_buffer_size.
411
412 · --safe-recover, -o
413
414 Do a repair using an old recovery method that reads through all
415 rows in order and updates all index trees based on the rows found.
416 This is an order of magnitude slower than --recover, but can handle
417 a couple of very unlikely cases that --recover cannot. This
418 recovery method also uses much less disk space than --recover.
419 Normally, you should repair first using --recover, and then with
420 --safe-recover only if --recover fails.
421
422 If you have lots of memory, you should increase the value of
423 key_buffer_size.
424
425 · --set-character-set=name
426
427 Change the character set used by the table indexes. This option was
428 replaced by --set-collation in MySQL 5.0.3.
429
430 · --set-collation=name
431
432 Specify the collation to use for sorting table indexes. The
433 character set name is implied by the first part of the collation
434 name.
435
436 · --sort-recover, -n
437
438 Force myisamchk to use sorting to resolve the keys even if the
439 temporary files would be very large.
440
441 · --tmpdir=path, -t path
442
443 The path of the directory to be used for storing temporary files.
444 If this is not set, myisamchk uses the value of the TMPDIR
445 environment variable. --tmpdir can be set to a list of directory
446 paths that are used successively in round-robin fashion for
447 creating temporary files. The separator character between directory
448 names is the colon (“:”) on Unix and the semicolon (“;”) on
449 Windows, NetWare, and OS/2.
450
451 · --unpack, -u
452
453 Unpack a table that was packed with myisampack.
454
456 myisamchk supports the following options for actions other than table
457 checks and repairs:
458
459 · --analyze, -a
460
461 Analyze the distribution of key values. This improves join
462 performance by enabling the join optimizer to better choose the
463 order in which to join the tables and which indexes it should use.
464 To obtain information about the key distribution, use a myisamchk
465 --description --verbose tbl_name command or the SHOW INDEX FROM
466 tbl_name statement.
467
468 · --block-search=offset, -b offset
469
470 Find the record that a block at the given offset belongs to.
471
472 · --description, -d
473
474 Print some descriptive information about the table. Specifying the
475 --verbose option once or twice produces additional information. See
476 the section called “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
477
478 · --set-auto-increment[=value], -A[value]
479
480 Force AUTO_INCREMENT numbering for new records to start at the
481 given value (or higher, if there are existing records with
482 AUTO_INCREMENT values this large). If value is not specified,
483 AUTO_INCREMENT numbers for new records begin with the largest value
484 currently in the table, plus one.
485
486 · --sort-index, -S
487
488 Sort the index tree blocks in high-low order. This optimizes seeks
489 and makes table scans that use indexes faster.
490
491 · --sort-records=N, -R N
492
493 Sort records according to a particular index. This makes your data
494 much more localized and may speed up range-based SELECT and ORDER
495 BY operations that use this index. (The first time you use this
496 option to sort a table, it may be very slow.) To determine a
497 table´s index numbers, use SHOW INDEX, which displays a table´s
498 indexes in the same order that myisamchk sees them. Indexes are
499 numbered beginning with 1.
500
501 If keys are not packed (PACK_KEYS=0), they have the same length, so
502 when myisamchk sorts and moves records, it just overwrites record
503 offsets in the index. If keys are packed (PACK_KEYS=1), myisamchk
504 must unpack key blocks first, then re-create indexes and pack the
505 key blocks again. (In this case, re-creating indexes is faster than
506 updating offsets for each index.)
507
509 To obtain a description of a MyISAM table or statistics about it, use
510 the commands shown here. The output from these commands is explained
511 later in this section.
512
513 · myisamchk -d tbl_name
514
515 Runs myisamchk in “describe mode” to produce a description of your
516 table. If you start the MySQL server with external locking
517 disabled, myisamchk may report an error for a table that is updated
518 while it runs. However, because myisamchk does not change the table
519 in describe mode, there is no risk of destroying data.
520
521 · myisamchk -dv tbl_name
522
523 Adding -v runs myisamchk in verbose mode so that it produces more
524 information about the table. Adding -v a second time produces even
525 more information.
526
527 · myisamchk -eis tbl_name
528
529 Shows only the most important information from a table. This
530 operation is slow because it must read the entire table.
531
532 · myisamchk -eiv tbl_name
533
534 This is like -eis, but tells you what is being done.
535
536 The tbl_name argument can be either the name of a MyISAM table or the
537 name of its index file, as described in myisamchk(1). Multiple tbl_name
538 arguments can be given.
539
540 Suppose that a table named person has the following structure. (The
541 MAX_ROWS table option is included so that in the example output from
542 myisamchk shown later, some values are smaller and fit the output
543 format more easily.)
544
545 CREATE TABLE person
546 (
547 id INT NOT NULL AUTO_INCREMENT,
548 last_name VARCHAR(20) NOT NULL,
549 first_name VARCHAR(20) NOT NULL,
550 birth DATE,
551 death DATE,
552 PRIMARY KEY (id),
553 INDEX (last_name, first_name),
554 INDEX (birth)
555 ) MAX_ROWS = 1000000;
556
557 Suppose also that the table has these data and index file sizes:
558
559 -rw-rw---- 1 mysql mysql 9347072 Aug 19 11:47 person.MYD
560 -rw-rw---- 1 mysql mysql 6066176 Aug 19 11:47 person.MYI
561
562 Example of myisamchk -dvv output:
563
564 MyISAM file: person
565 Record format: Packed
566 Character set: latin1_swedish_ci (8)
567 File-version: 1
568 Creation time: 2009-08-19 16:47:41
569 Recover time: 2009-08-19 16:47:56
570 Status: checked,analyzed,optimized keys
571 Auto increment key: 1 Last value: 306688
572 Data records: 306688 Deleted blocks: 0
573 Datafile parts: 306688 Deleted data: 0
574 Datafile pointer (bytes): 4 Keyfile pointer (bytes): 3
575 Datafile length: 9347072 Keyfile length: 6066176
576 Max datafile length: 4294967294 Max keyfile length: 17179868159
577 Recordlength: 54
578 table description:
579 Key Start Len Index Type Rec/key Root Blocksize
580 1 2 4 unique long 1 99328 1024
581 2 6 20 multip. varchar prefix 512 3563520 1024
582 27 20 varchar 512
583 3 48 3 multip. uint24 NULL 306688 6065152 1024
584 Field Start Length Nullpos Nullbit Type
585 1 1 1
586 2 2 4 no zeros
587 3 6 21 varchar
588 4 27 21 varchar
589 5 48 3 1 1 no zeros
590 6 51 3 1 2 no zeros
591
592 Explanations for the types of information myisamchk produces are given
593 here. “Keyfile” refers to the index file. “Record” and “row” are
594 synonymous, as are “field” and “column.”
595
596 The initial part of the table description contains these values:
597
598 · MyISAM file
599
600 Name of the MyISAM (index) file.
601
602 · Record format
603
604 The format used to store table rows. The preceding examples use
605 Fixed length. Other possible values are Compressed and Packed.
606 (Packed corresponds to what SHOW TABLE STATUS reports as Dynamic.)
607
608 · Chararacter set
609
610 The table default character set.
611
612 · File-version
613
614 Version of MyISAM format. Currently always 1.
615
616 · Creation time
617
618 When the data file was created.
619
620 · Recover time
621
622 When the index/data file was last reconstructed.
623
624 · Status
625
626 Table status flags. Possible values are crashed, open, changed,
627 analyzed, optimized keys, and sorted index pages.
628
629 · Auto increment key, Last value
630
631 The key number associated the table´s AUTO_INCREMENT column, and
632 the most recently generated value for this column. These fields do
633 not appear if there is no such column.
634
635 · Data records
636
637 The number of rows in the table.
638
639 · Deleted blocks
640
641 How many deleted blocks still have reserved space. You can optimize
642 your table to minimize this space. See Section 6.6.4, “MyISAM Table
643 Optimization”.
644
645 · Datafile parts
646
647 For dynamic-row format, this indicates how many data blocks there
648 are. For an optimized table without fragmented rows, this is the
649 same as Data records.
650
651 · Deleted data
652
653 How many bytes of unreclaimed deleted data there are. You can
654 optimize your table to minimize this space. See Section 6.6.4,
655 “MyISAM Table Optimization”.
656
657 · Datafile pointer
658
659 The size of the data file pointer, in bytes. It is usually 2, 3, 4,
660 or 5 bytes. Most tables manage with 2 bytes, but this cannot be
661 controlled from MySQL yet. For fixed tables, this is a row address.
662 For dynamic tables, this is a byte address.
663
664 · Keyfile pointer
665
666 The size of the index file pointer, in bytes. It is usually 1, 2,
667 or 3 bytes. Most tables manage with 2 bytes, but this is calculated
668 automatically by MySQL. It is always a block address.
669
670 · Max datafile length
671
672 How long the table data file can become, in bytes.
673
674 · Max keyfile length
675
676 How long the table index file can become, in bytes.
677
678 · Recordlength
679
680 How much space each row takes, in bytes.
681
682 The table description part of the output includes a list of all keys in
683 the table. For each key, myisamchk displays some low-level information:
684
685 · Key
686
687 This key´s number. This value is shown only for the first column of
688 the key. If this value is missing, the line corresponds to the
689 second or later column of a multiple-column key. For the table
690 shown in the example, there are two table description lines for the
691 second index. This indicates that it is a multiple-part index with
692 two parts.
693
694 · Start
695
696 Where in the row this portion of the index starts.
697
698 · Len
699
700 How long this portion of the index is. For packed numbers, this
701 should always be the full length of the column. For strings, it may
702 be shorter than the full length of the indexed column, because you
703 can index a prefix of a string column. The total length of a
704 multiple-part key is the sum of the Len values for all key parts.
705
706 · Index
707
708 Whether a key value can exist multiple times in the index. Possible
709 values are unique or multip. (multiple).
710
711 · Type
712
713 What data type this portion of the index has. This is a MyISAM data
714 type with the possible values packed, stripped, or empty.
715
716 · Root
717
718 Address of the root index block.
719
720 · Blocksize
721
722 The size of each index block. By default this is 1024, but the
723 value may be changed at compile time when MySQL is built from
724 source.
725
726 · Rec/key
727
728 This is a statistical value used by the optimizer. It tells how
729 many rows there are per value for this index. A unique index always
730 has a value of 1. This may be updated after a table is loaded (or
731 greatly changed) with myisamchk -a. If this is not updated at all,
732 a default value of 30 is given.
733
734 The last part of the output provides information about each column:
735
736 · Field
737
738 The column number.
739
740 · Start
741
742 The byte position of the column within table rows.
743
744 · Length
745
746 The length of the column in bytes.
747
748 · Nullpos, Nullbit
749
750 For columns that can be NULL, MyISAM stores NULL values as a flag
751 in a byte. Depending on how many nullable columns there are, there
752 can be one or more bytes used for this purpose. The Nullpos and
753 Nullbit values, if nonempty, indicate which byte and bit contains
754 that flag indicating whether the column is NULL.
755
756 The position and number of bytes used to store NULL flags is shown
757 in the line for field 1. This is why there are six Field lines for
758 the person table even though it has only five columns.
759
760 · Type
761
762 The data type. The value may contain any of the following
763 descriptors:
764
765 · constant
766
767 All rows have the same value.
768
769 · no endspace
770
771 Do not store endspace.
772
773 · no endspace, not_always
774
775 Do not store endspace and do not do endspace compression for
776 all values.
777
778 · no endspace, no empty
779
780 Do not store endspace. Do not store empty values.
781
782 · table-lookup
783
784 The column was converted to an ENUM.
785
786 · zerofill(N)
787
788 The most significant N bytes in the value are always 0 and are
789 not stored.
790
791 · no zeros
792
793 Do not store zeros.
794
795 · always zero
796
797 Zero values are stored using one bit.
798
799 · Huff tree
800
801 The number of the Huffman tree associated with the column.
802
803 · Bits
804
805 The number of bits used in the Huffman tree.
806
807 The Huff tree and Bits fields are displayed if the table has been
808 compressed with myisampack. See myisampack(1), for an example of this
809 information.
810
811 Example of myisamchk -eiv output:
812
813 Checking MyISAM file: person
814 Data records: 306688 Deleted blocks: 0
815 - check file-size
816 - check record delete-chain
817 No recordlinks
818 - check key delete-chain
819 block_size 1024:
820 - check index reference
821 - check data record references index: 1
822 Key: 1: Keyblocks used: 98% Packed: 0% Max levels: 3
823 - check data record references index: 2
824 Key: 2: Keyblocks used: 99% Packed: 97% Max levels: 3
825 - check data record references index: 3
826 Key: 3: Keyblocks used: 98% Packed: -14% Max levels: 3
827 Total: Keyblocks used: 98% Packed: 89%
828 - check records and index references*** LOTS OF ROW NUMBERS DELETED ***
829 Records: 306688 M.recordlength: 25 Packed: 83%
830 Recordspace used: 97% Empty space: 2% Blocks/Record: 1.00
831 Record blocks: 306688 Delete blocks: 0
832 Record data: 7934464 Deleted data: 0
833 Lost space: 256512 Linkdata: 1156096
834 User time 43.08, System time 1.68
835 Maximum resident set size 0, Integral resident set size 0
836 Non-physical pagefaults 0, Physical pagefaults 0, Swaps 0
837 Blocks in 0 out 7, Messages in 0 out 0, Signals 0
838 Voluntary context switches 0, Involuntary context switches 0
839 Maximum memory usage: 1046926 bytes (1023k)
840
841 myisamchk -eiv output includes the following information:
842
843 · Data records
844
845 The number of rows in the table.
846
847 · Deleted blocks
848
849 How many deleted blocks still have reserved space. You can optimize
850 your table to minimize this space. See Section 6.6.4, “MyISAM Table
851 Optimization”.
852
853 · Key
854
855 The key number.
856
857 · Keyblocks used
858
859 What percentage of the keyblocks are used. When a table has just
860 been reorganized with myisamchk, the values are very high (very
861 near theoretical maximum).
862
863 · Packed
864
865 MySQL tries to pack key values that have a common suffix. This can
866 only be used for indexes on CHAR and VARCHAR columns. For long
867 indexed strings that have similar leftmost parts, this can
868 significantly reduce the space used. In the preceding example, the
869 second key is 40 bytes long and a 97% reduction in space is
870 achieved.
871
872 · Max levels
873
874 How deep the B-tree for this key is. Large tables with long key
875 values get high values.
876
877 · Records
878
879 How many rows are in the table.
880
881 · M.recordlength
882
883 The average row length. This is the exact row length for tables
884 with fixed-length rows, because all rows have the same length.
885
886 · Packed
887
888 MySQL strips spaces from the end of strings. The Packed value
889 indicates the percentage of savings achieved by doing this.
890
891 · Recordspace used
892
893 What percentage of the data file is used.
894
895 · Empty space
896
897 What percentage of the data file is unused.
898
899 · Blocks/Record
900
901 Average number of blocks per row (that is, how many links a
902 fragmented row is composed of). This is always 1.0 for fixed-format
903 tables. This value should stay as close to 1.0 as possible. If it
904 gets too large, you can reorganize the table. See Section 6.6.4,
905 “MyISAM Table Optimization”.
906
907 · Recordblocks
908
909 How many blocks (links) are used. For fixed-format tables, this is
910 the same as the number of rows.
911
912 · Deleteblocks
913
914 How many blocks (links) are deleted.
915
916 · Recorddata
917
918 How many bytes in the data file are used.
919
920 · Deleted data
921
922 How many bytes in the data file are deleted (unused).
923
924 · Lost space
925
926 If a row is updated to a shorter length, some space is lost. This
927 is the sum of all such losses, in bytes.
928
929 · Linkdata
930
931 When the dynamic table format is used, row fragments are linked
932 with pointers (4 to 7 bytes each). Linkdata is the sum of the
933 amount of storage used by all such pointers.
934
936 Memory allocation is important when you run myisamchk. myisamchk uses
937 no more memory than its memory-related variables are set to. If you are
938 going to use myisamchk on very large tables, you should first decide
939 how much memory you want it to use. The default is to use only about
940 3MB to perform repairs. By using larger values, you can get myisamchk
941 to operate faster. For example, if you have more than 512MB RAM
942 available, you could use options such as these (in addition to any
943 other options you might specify):
944
945 shell> myisamchk --sort_buffer_size=256M \
946 --key_buffer_size=512M \
947 --read_buffer_size=64M \
948 --write_buffer_size=64M ...
949
950 Using --sort_buffer_size=16M is probably enough for most cases.
951
952 Be aware that myisamchk uses temporary files in TMPDIR. If TMPDIR
953 points to a memory file system, out of memory errors can easily occur.
954 If this happens, run myisamchk with the --tmpdir=path option to specify
955 a directory located on a file system that has more space.
956
957 When performing repair operations, myisamchk also needs a lot of disk
958 space:
959
960 · Twice the size of the data file (the original file and a copy).
961 This space is not needed if you do a repair with --quick; in this
962 case, only the index file is re-created. This space must be
963 available on the same file system as the original data file, as the
964 copy is created in the same directory as the original.
965
966 · Space for the new index file that replaces the old one. The old
967 index file is truncated at the start of the repair operation, so
968 you usually ignore this space. This space must be available on the
969 same file system as the original data file.
970
971 · When using --recover or --sort-recover (but not when using
972 --safe-recover), you need space on disk for sorting. This space is
973 allocated in the temporary directory (specified by TMPDIR or
974 --tmpdir=path). The following formula yields the amount of space
975 required:
976
977 (largest_key + row_pointer_length) * number_of_rows * 2
978
979 You can check the length of the keys and the row_pointer_length
980 with myisamchk -dv tbl_name (see the section called “OBTAINING
981 TABLE INFORMATION WITH MYISAMCHK”). The row_pointer_length and
982 number_of_rows values are the Datafile pointer and Data records
983 values in the table description. To determine the largest_key
984 value, check the Key lines in the table description. The Len column
985 indicates the number of bytes for each key part. For a
986 multiple-column index, the key size is the sum of the Len values
987 for all key parts.
988
989 If you have a problem with disk space during repair, you can try
990 --safe-recover instead of --recover.
991
993 Copyright © 1997, 2011, Oracle and/or its affiliates. All rights
994 reserved.
995
996 This documentation is free software; you can redistribute it and/or
997 modify it only under the terms of the GNU General Public License as
998 published by the Free Software Foundation; version 2 of the License.
999
1000 This documentation is distributed in the hope that it will be useful,
1001 but WITHOUT ANY WARRANTY; without even the implied warranty of
1002 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1003 General Public License for more details.
1004
1005 You should have received a copy of the GNU General Public License along
1006 with the program; if not, write to the Free Software Foundation, Inc.,
1007 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
1008 http://www.gnu.org/licenses/.
1009
1010
1012 For more information, please refer to the MySQL Reference Manual, which
1013 may already be installed locally and which is also available online at
1014 http://dev.mysql.com/doc/.
1015
1017 Oracle Corporation (http://dev.mysql.com/).
1018
1019
1020
1021MySQL 5.1 10/26/2011 MYISAMCHK(1)