1MYISAMCHK(1) MariaDB 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 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 MariaDB 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 MariaDB server while running myisamchk, or to lock
85 all 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.
105
106 myisamchk supports the following options, which can be specified on the
107 command line or in the [myisamchk] option file group.
108
110 The options described in this section can be used for any type of table
111 maintenance operation performed by myisamchk. The sections following
112 this one describe options that pertain only to specific operations,
113 such as table checking or repairing.
114
115 · --help, -?
116
117 Display a help message and exit. Options are grouped by type of
118 operation.
119
120 · --HELP, -H
121
122 Display a help message and exit. Options are presented in a single
123 list.
124
125 · --debug=debug_options, -# debug_options
126
127 Write a debugging log. A typical debug_options string is
128 ´d:t:o,file_name´. The default is ´d:t:o,/tmp/myisamchk.trace´.
129
130 · --silent, -s
131
132 Silent mode. Write output only when errors occur. You can use -s
133 twice (-ss) to make myisamchk very silent.
134
135 · --verbose, -v
136
137 Verbose mode. Print more information about what the program does.
138 This can be used with -d and -e. Use -v multiple times (-vv, -vvv)
139 for even more output.
140
141 · --version, -V
142
143 Display version information and exit.
144
145 · --wait, -w
146
147 Instead of terminating with an error if the table is locked, wait
148 until the table is unlocked before continuing. If you are running
149 mysqld with external locking disabled, the table can be locked only
150 by another myisamchk command.
151
152 · --print-defaults
153
154 Print the program argument list and exit.
155
156 · --no-defaults
157
158 Don't read default options from any option file.
159
160 · --defaults-file=#
161
162 Only read default options from the given file.
163
164 · --defaults-extra-file=#
165
166 Read this file after the global files are read.
167
168 You can also set the following variables by using --var_name=value
169 syntax:
170
171 ┌─────────────────────┬───────────────────┐
172 │Variable │ Default Value │
173 ├─────────────────────┼───────────────────┤
174 │decode_bits │ 9 │
175 ├─────────────────────┼───────────────────┤
176 │ft_max_word_len │ version-dependent │
177 ├─────────────────────┼───────────────────┤
178 │ft_min_word_len │ 4 │
179 ├─────────────────────┼───────────────────┤
180 │ft_stopword_file │ built-in list │
181 ├─────────────────────┼───────────────────┤
182 │key_buffer_size │ 523264 │
183 ├─────────────────────┼───────────────────┤
184 │key_cache_block_size │ 1024 │
185 ├─────────────────────┼───────────────────┤
186 │myisam_block_size │ 1024 │
187 ├─────────────────────┼───────────────────┤
188 │read_buffer_size │ 262136 │
189 ├─────────────────────┼───────────────────┤
190 │sort_buffer_size │ 2097144 │
191 ├─────────────────────┼───────────────────┤
192 │sort_key_blocks │ 16 │
193 ├─────────────────────┼───────────────────┤
194 │stats_method │ nulls_unequal │
195 ├─────────────────────┼───────────────────┤
196 │write_buffer_size │ 262136 │
197 └─────────────────────┴───────────────────┘
198
199 The possible myisamchk variables and their default values can be
200 examined with myisamchk --help:
201
202 sort_buffer_size is used when the keys are repaired by sorting keys,
203 which is the normal case when you use --recover.
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 sort_buffer_size variables to about 25% of your available memory. You
225 can set both variables to large values, because only one of them is
226 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 7.4.7, “MyISAM Index Statistics Collection”.
235
236 ft_min_word_len and ft_max_word_len indicate the minimum and maximum
237 word length for FULLTEXT indexes. ft_stopword_file names the stopword
238 file. These need to be set under the following circumstances.
239
240 If you use myisamchk to perform an operation that modifies table
241 indexes (such as repair or analyze), the FULLTEXT indexes are rebuilt
242 using the default full-text parameter values for minimum and maximum
243 word length and the stopword file unless you specify otherwise. This
244 can result in queries failing.
245
246 The problem occurs because these parameters are known only by the
247 server. They are not stored in MyISAM index files. To avoid the problem
248 if you have modified the minimum or maximum word length or the stopword
249 file in the server, specify the same ft_min_word_len, ft_max_word_len,
250 and ft_stopword_file values to myisamchk that you use for mysqld. For
251 example, if you have set the minimum word length to 3, you can repair a
252 table with myisamchk like this:
253
254 shell> myisamchk --recover --ft_min_word_len=3 tbl_name.MYI
255
256 To ensure that myisamchk and the server use the same values for
257 full-text parameters, you can place each one in both the [mysqld] and
258 [myisamchk] sections of an option file:
259
260 [mysqld]
261 ft_min_word_len=3
262 [myisamchk]
263 ft_min_word_len=3
264
265 An alternative to using myisamchk is to use the REPAIR TABLE, ANALYZE
266 TABLE, OPTIMIZE TABLE, or ALTER TABLE. These statements are performed
267 by the server, which knows the proper full-text parameter values to
268 use.
269
271 myisamchk supports the following options for table checking operations:
272
273 · --check, -c
274
275 Check the table for errors. This is the default operation if you
276 specify no option that selects an operation type explicitly.
277
278 · --check-only-changed, -C
279
280 Check only tables that have changed since the last check.
281
282 · --extend-check, -e
283
284 Check the table very thoroughly. This is quite slow if the table
285 has many indexes. This option should only be used in extreme cases.
286 Normally, myisamchk or myisamchk --medium-check should be able to
287 determine whether there are any errors in the table.
288
289 If you are using --extend-check and have plenty of memory, setting
290 the key_buffer_size variable to a large value helps the repair
291 operation run faster.
292
293 For a description of the output format, see the section called
294 “MYISAMCHK TABLE INFORMATION”.
295
296 · --fast, -F
297
298 Check only tables that haven´t been closed properly.
299
300 · --force, -f
301
302 Do a repair operation automatically if myisamchk finds any errors
303 in the table. The repair type is the same as that specified with
304 the --recover or -r option. States will be updated as with
305 --update-state.
306
307 · --information, -i
308
309 Print informational statistics about the table that is checked.
310
311 · --medium-check, -m
312
313 Do a check that is faster than an --extend-check operation. This
314 finds only 99.99% of all errors, which should be good enough in
315 most cases.
316
317 · --read-only, -T
318
319 Do not mark the table as checked. This is useful if you use
320 myisamchk to check a table that is in use by some other application
321 that does not use locking, such as mysqld when run with external
322 locking disabled.
323
324 · --update-state, -U
325
326 Store information in the .MYI file to indicate when the table was
327 checked and whether the table crashed. This should be used to get
328 full benefit of the --check-only-changed option, but you shouldn´t
329 use this option if the mysqld server is using the table and you are
330 running it with external locking disabled.
331
333 myisamchk supports the following options for table repair operations
334 (operations performed when an option such as --recover or
335 --safe-recover is given):
336
337 · --backup, -B
338
339 Make a backup of the .MYD file as file_name-time.BAK
340
341 · --character-sets-dir=path
342
343 The directory where character sets are installed.
344
345 · --correct-checksum
346
347 Correct the checksum information for the table.
348
349 · --create-missing-keys
350
351 Create missing keys. This assumes that the data file is correct and
352 that the number of rows stored in the index file is correct.
353 Enables --quick.
354
355
356 · --data-file-length=len, -D len
357
358 The maximum length of the data file (when re-creating data file
359 when it is “full”).
360
361 · --extend-check, -e
362
363 Do a repair that tries to recover every possible row from the data
364 file. Normally, this also finds a lot of garbage rows. Do not use
365 this option unless you are desperate.
366
367 For a description of the output format, see the section called
368 “MYISAMCHK TABLE INFORMATION”.
369
370 · --force, -f
371
372 Overwrite old intermediate files (files with names like
373 tbl_name.TMD) instead of aborting. Add another --force to avoid
374 'myisam_sort_buffer_size is too small' errors. In this case we will
375 attempt to do the repair with the given myisam_sort_buffer_size and
376 dynamically allocate as many management buffers as needed.
377
378 · --keys-used=val, -k val
379
380 For myisamchk, the option value is a bit-value that indicates which
381 indexes to update. Each binary bit of the option value corresponds
382 to a table index, where the first index is bit 0. An option value
383 of 0 disables updates to all indexes, which can be used to get
384 faster inserts. Deactivated indexes can be reactivated by using
385 myisamchk -r.
386
387 · --max-record-length=len
388
389 Skip rows larger than the given length if myisamchk cannot allocate
390 memory to hold them.
391
392 · --parallel-recover, -p
393
394 Use the same technique as -r and -n, but create all the keys in
395 parallel, using different threads. This is beta-quality code. Use
396 at your own risk!
397
398 · --quick, -q
399
400 Achieve a faster repair by modifying only the index file, not the
401 data file. You can specify this option twice to force myisamchk to
402 modify the original data file in case of duplicate keys. NOTE:
403 Tables where the data file is corrupted can't be fixed with this
404 option.
405
406 · --recover, -r
407
408 Do a repair that can fix almost any problem except unique keys that
409 are not unique (which is an extremely unlikely error with MyISAM
410 tables). If you want to recover a table, this is the option to try
411 first. You should try --safe-recover only if myisamchk reports that
412 the table cannot be recovered using --recover. (In the unlikely
413 case that --recover fails, the data file remains intact.)
414
415 If you have lots of memory, you should increase the value of
416 sort_buffer_size.
417
418 · --safe-recover, -o
419
420 Do a repair using an old recovery method that reads through all
421 rows in order and updates all index trees based on the rows found.
422 This is an order of magnitude slower than --recover, but can handle
423 a couple of very unlikely cases that --recover cannot. This
424 recovery method also uses much less disk space than --recover.
425 Normally, you should repair first using --recover, and then with
426 --safe-recover only if --recover fails.
427
428 If you have lots of memory, you should increase the value of
429 key_buffer_size.
430
431 · --set-collation=name
432
433 Specify the collation to use for sorting table indexes. The
434 character set name is implied by the first part of the collation
435 name.
436
437 · --sort-recover, -n
438
439 Force myisamchk to use sorting to resolve the keys even if the
440 temporary files would be very large.
441
442 · --tmpdir=path, -t path
443
444 The path of the directory to be used for storing temporary files.
445 If this is not set, myisamchk uses the value of the TMPDIR
446 environment variable. tmpdir can be set to a list of directory
447 paths that are used successively in round-robin fashion for
448 creating temporary files. The separator character between directory
449 names is the colon (“:”) on Unix and the semicolon (“;”) on
450 Windows, NetWare, and OS/2.
451
452 · --unpack, -u
453
454 Unpack a table that was packed with myisampack.
455
457 myisamchk supports the following options for actions other than table
458 checks and repairs:
459
460 · --analyze, -a
461
462 Analyze the distribution of key values. This improves join
463 performance by enabling the join optimizer to better choose the
464 order in which to join the tables and which indexes it should use.
465 To obtain information about the key distribution, use a myisamchk
466 --description --verbose tbl_name command or the SHOW INDEX FROM
467 tbl_name statement.
468
469 · --block-search=offset, -b offset
470
471 Find the record that a block at the given offset belongs to.
472
473 · --description, -d
474
475 Print some descriptive information about the table. Specifying the
476 --verbose option once or twice produces additional information. See
477 the section called “MYISAMCHK TABLE INFORMATION”.
478
479 · --set-auto-increment[=value], -A[value]
480
481 Force AUTO_INCREMENT numbering for new records to start at the
482 given value (or higher, if there are existing records with
483 AUTO_INCREMENT values this large). If value is not specified,
484 AUTO_INCREMENT numbers for new records begin with the largest value
485 currently in the table, plus one.
486
487 · --sort-index, -S
488
489 Sort the index tree blocks in high-low order. This optimizes seeks
490 and makes table scans that use indexes faster.
491
492 · --sort-records=N, -R N
493
494 Sort records according to a particular index. This makes your data
495 much more localized and may speed up range-based SELECT and ORDER
496 BY operations that use this index. (The first time you use this
497 option to sort a table, it may be very slow.) To determine a
498 table´s index numbers, use SHOW INDEX, which displays a table´s
499 indexes in the same order that myisamchk sees them. Indexes are
500 numbered beginning with 1.
501
502 If keys are not packed (PACK_KEYS=0), they have the same length, so
503 when myisamchk sorts and moves records, it just overwrites record
504 offsets in the index. If keys are packed (PACK_KEYS=1), myisamchk
505 must unpack key blocks first, then re-create indexes and pack the
506 key blocks again. (In this case, re-creating indexes is faster than
507 updating offsets for each index.)
508
509 · --stats-method=name
510
511 Specifies how index statistics collection code should treat NULLs.
512 Possible values of name are "nulls_unequal" (default),
513 "nulls_equal" (emulate MySQL 4 behavior), and "nulls_ignored".
514
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 MariaDB 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 6.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 6.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 MariaDB yet. For fixed tables, this is a row
669 address. 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 MariaDB. 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 MariaDB 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 6.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 MariaDB tries to pack key values that have a common suffix. This
874 can 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 MariaDB 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 6.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
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 32MB RAM, you
950 could use options such as these (in addition to any other options you
951 might specify):
952
953 shell> myisamchk --sort_buffer_size=16M \
954 --key_buffer_size=16M \
955 --read_buffer_size=1M \
956 --write_buffer_size=1M ...
957
958 Using --sort_buffer_size=16M should probably be 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 “MYISAMCHK
989 TABLE INFORMATION”). The row_pointer_length and number_of_rows
990 values are the Datafile pointer and Data records values in the
991 table description. To determine the largest_key value, check the
992 Key lines in the table description. The Len column indicates the
993 number of bytes for each key part. For a multiple-column index, the
994 key size is the sum of the Len values for all key parts.
995
996 If you have a problem with disk space during repair, you can try
997 --safe-recover instead of --recover.
998
1000 Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.,
1001 2010-2015 MariaDB Foundation
1002
1003 This documentation is free software; you can redistribute it and/or
1004 modify it only under the terms of the GNU General Public License as
1005 published by the Free Software Foundation; version 2 of the License.
1006
1007 This documentation is distributed in the hope that it will be useful,
1008 but WITHOUT ANY WARRANTY; without even the implied warranty of
1009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1010 General Public License for more details.
1011
1012 You should have received a copy of the GNU General Public License along
1013 with the program; if not, write to the Free Software Foundation, Inc.,
1014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
1015 http://www.gnu.org/licenses/.
1016
1017
1019 For more information, please refer to the MariaDB Knowledge Base,
1020 available online at https://mariadb.com/kb/
1021
1023 MariaDB Foundation (http://www.mariadb.org/).
1024
1025
1026
1027MariaDB 10.3 9 May 2017 MYISAMCHK(1)