To obtain a description of a MyISAM table or
statistics about it, use the commands shown here. The output
from these commands is explained later in this section.
Runs myisamchk in “describe mode” to produce a description of your table. If you start the MySQL server with external locking disabled, myisamchk may report an error for a table that is updated while it runs. However, because myisamchk does not change the table in describe mode, there is no risk of destroying data.
Adding
-vruns myisamchk in verbose mode so that it produces more information about the table. Adding-va second time produces even more information.Shows only the most important information from a table. This operation is slow because it must read the entire table.
This is like
-eis, but tells you what is being done.
The tbl_name argument can be either
the name of a MyISAM table or the name of its
index file, as described in Section 6.6.4, “myisamchk — MyISAM Table-Maintenance Utility”.
Multiple tbl_name arguments can be
given.
Suppose that a table named person has the
following structure. (The MAX_ROWS table
option is included so that in the example output from
myisamchk shown later, some values are
smaller and fit the output format more easily.)
CREATE TABLE person
(
id INT NOT NULL AUTO_INCREMENT,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
birth DATE,
death DATE,
PRIMARY KEY (id),
INDEX (last_name, first_name),
INDEX (birth)
) MAX_ROWS = 1000000 ENGINE=MYISAM;Suppose also that the table has these data and index file sizes:
-rw-rw---- 1 mysql mysql 9347072 Aug 19 11:47 person.MYD
-rw-rw---- 1 mysql mysql 6066176 Aug 19 11:47 person.MYIExample of myisamchk -dvv output:
MyISAM file: person
Record format: Packed
Character set: utf8mb4_0900_ai_ci (255)
File-version: 1
Creation time: 2017-03-30 21:21:30
Status: checked,analyzed,optimized keys,sorted index pages
Auto increment key: 1 Last value: 306688
Data records: 306688 Deleted blocks: 0
Datafile parts: 306688 Deleted data: 0
Datafile pointer (bytes): 4 Keyfile pointer (bytes): 3
Datafile length: 9347072 Keyfile length: 6066176
Max datafile length: 4294967294 Max keyfile length: 17179868159
Recordlength: 54
table description:
Key Start Len Index Type Rec/key Root Blocksize
1 2 4 unique long 1 1024
2 6 80 multip. varchar prefix 0 1024
87 80 varchar 0
3 168 3 multip. uint24 NULL 0 1024
Field Start Length Nullpos Nullbit Type
1 1 1
2 2 4 no zeros
3 6 81 varchar
4 87 81 varchar
5 168 3 1 1 no zeros
6 171 3 1 2 no zerosExplanations for the types of information myisamchk produces are given here. “Keyfile” refers to the index file. “Record” and “row” are synonymous, as are “field” and “column.”
The initial part of the table description contains these values:
MyISAM fileName of the
MyISAM(index) file.Record formatThe format used to store table rows. The preceding examples use
Fixed length. Other possible values areCompressedandPacked. (Packedcorresponds to whatSHOW TABLE STATUSreports asDynamic.)Chararacter setThe table default character set.
File-versionVersion of
MyISAMformat. Always 1.Creation timeWhen the data file was created.
Recover timeWhen the index/data file was last reconstructed.
StatusTable status flags. Possible values are
crashed,open,changed,analyzed,optimized keys, andsorted index pages.Auto increment key,Last valueThe key number associated the table's
AUTO_INCREMENTcolumn, and the most recently generated value for this column. These fields do not appear if there is no such column.Data recordsThe number of rows in the table.
Deleted blocksHow many deleted blocks still have reserved space. You can optimize your table to minimize this space. See Section 9.6.4, “MyISAM Table Optimization”.
Datafile partsFor dynamic-row format, this indicates how many data blocks there are. For an optimized table without fragmented rows, this is the same as
Data records.Deleted dataHow many bytes of unreclaimed deleted data there are. You can optimize your table to minimize this space. See Section 9.6.4, “MyISAM Table Optimization”.
Datafile pointerThe size of the data file pointer, in bytes. It is usually 2, 3, 4, or 5 bytes. Most tables manage with 2 bytes, but this cannot be controlled from MySQL yet. For fixed tables, this is a row address. For dynamic tables, this is a byte address.
Keyfile pointerThe size of the index file pointer, in bytes. It is usually 1, 2, or 3 bytes. Most tables manage with 2 bytes, but this is calculated automatically by MySQL. It is always a block address.
Max datafile lengthHow long the table data file can become, in bytes.
Max keyfile lengthHow long the table index file can become, in bytes.
RecordlengthHow much space each row takes, in bytes.
The table description part of the output
includes a list of all keys in the table. For each key,
myisamchk displays some low-level
information:
KeyThis key's number. This value is shown only for the first column of the key. If this value is missing, the line corresponds to the second or later column of a multiple-column key. For the table shown in the example, there are two
table descriptionlines for the second index. This indicates that it is a multiple-part index with two parts.StartWhere in the row this portion of the index starts.
LenHow long this portion of the index is. For packed numbers, this should always be the full length of the column. For strings, it may be shorter than the full length of the indexed column, because you can index a prefix of a string column. The total length of a multiple-part key is the sum of the
Lenvalues for all key parts.IndexWhether a key value can exist multiple times in the index. Possible values are
uniqueormultip.(multiple).TypeWhat data type this portion of the index has. This is a
MyISAMdata type with the possible valuespacked,stripped, orempty.RootAddress of the root index block.
BlocksizeThe size of each index block. By default this is 1024, but the value may be changed at compile time when MySQL is built from source.
Rec/keyThis is a statistical value used by the optimizer. It tells how many rows there are per value for this index. A unique index always has a value of 1. This may be updated after a table is loaded (or greatly changed) with myisamchk -a. If this is not updated at all, a default value of 30 is given.
The last part of the output provides information about each column:
FieldThe column number.
StartThe byte position of the column within table rows.
LengthThe length of the column in bytes.
Nullpos,NullbitFor columns that can be
NULL,MyISAMstoresNULLvalues as a flag in a byte. Depending on how many nullable columns there are, there can be one or more bytes used for this purpose. TheNullposandNullbitvalues, if nonempty, indicate which byte and bit contains that flag indicating whether the column isNULL.The position and number of bytes used to store
NULLflags is shown in the line for field 1. This is why there are sixFieldlines for thepersontable even though it has only five columns.TypeThe data type. The value may contain any of the following descriptors:
constantAll rows have the same value.
no endspaceDo not store endspace.
no endspace, not_alwaysDo not store endspace and do not do endspace compression for all values.
no endspace, no emptyDo not store endspace. Do not store empty values.
table-lookupThe column was converted to an
ENUM.zerofill(N)The most significant
Nbytes in the value are always 0 and are not stored.no zerosDo not store zeros.
always zeroZero values are stored using one bit.
Huff treeThe number of the Huffman tree associated with the column.
BitsThe number of bits used in the Huffman tree.
The Huff tree and Bits
fields are displayed if the table has been compressed with
myisampack. See Section 6.6.6, “myisampack — Generate Compressed, Read-Only MyISAM Tables”,
for an example of this information.
Example of myisamchk -eiv output:
Checking MyISAM file: person
Data records: 306688 Deleted blocks: 0
- check file-size
- check record delete-chain
No recordlinks
- check key delete-chain
block_size 1024:
- check index reference
- check data record references index: 1
Key: 1: Keyblocks used: 98% Packed: 0% Max levels: 3
- check data record references index: 2
Key: 2: Keyblocks used: 99% Packed: 97% Max levels: 3
- check data record references index: 3
Key: 3: Keyblocks used: 98% Packed: -14% Max levels: 3
Total: Keyblocks used: 98% Packed: 89%
- check records and index references
*** LOTS OF ROW NUMBERS DELETED ***
Records: 306688 M.recordlength: 25 Packed: 83%
Recordspace used: 97% Empty space: 2% Blocks/Record: 1.00
Record blocks: 306688 Delete blocks: 0
Record data: 7934464 Deleted data: 0
Lost space: 256512 Linkdata: 1156096
User time 43.08, System time 1.68
Maximum resident set size 0, Integral resident set size 0
Non-physical pagefaults 0, Physical pagefaults 0, Swaps 0
Blocks in 0 out 7, Messages in 0 out 0, Signals 0
Voluntary context switches 0, Involuntary context switches 0
Maximum memory usage: 1046926 bytes (1023k)myisamchk -eiv output includes the following information:
Data recordsThe number of rows in the table.
Deleted blocksHow many deleted blocks still have reserved space. You can optimize your table to minimize this space. See Section 9.6.4, “MyISAM Table Optimization”.
KeyThe key number.
Keyblocks usedWhat percentage of the keyblocks are used. When a table has just been reorganized with myisamchk, the values are very high (very near theoretical maximum).
PackedMySQL tries to pack key values that have a common suffix. This can only be used for indexes on
CHARandVARCHARcolumns. For long indexed strings that have similar leftmost parts, this can significantly reduce the space used. In the preceding example, the second key is 40 bytes long and a 97% reduction in space is achieved.Max levelsHow deep the B-tree for this key is. Large tables with long key values get high values.
RecordsHow many rows are in the table.
M.recordlengthThe average row length. This is the exact row length for tables with fixed-length rows, because all rows have the same length.
PackedMySQL strips spaces from the end of strings. The
Packedvalue indicates the percentage of savings achieved by doing this.Recordspace usedWhat percentage of the data file is used.
Empty spaceWhat percentage of the data file is unused.
Blocks/RecordAverage number of blocks per row (that is, how many links a fragmented row is composed of). This is always 1.0 for fixed-format tables. This value should stay as close to 1.0 as possible. If it gets too large, you can reorganize the table. See Section 9.6.4, “MyISAM Table Optimization”.
RecordblocksHow many blocks (links) are used. For fixed-format tables, this is the same as the number of rows.
DeleteblocksHow many blocks (links) are deleted.
RecorddataHow many bytes in the data file are used.
Deleted dataHow many bytes in the data file are deleted (unused).
Lost spaceIf a row is updated to a shorter length, some space is lost. This is the sum of all such losses, in bytes.
LinkdataWhen the dynamic table format is used, row fragments are linked with pointers (4 to 7 bytes each).
Linkdatais the sum of the amount of storage used by all such pointers.