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.MyISAM
表的描述或有关它的统计信息,请使用此处显示的命令。本节稍后将解释这些命令的输出。
Runs myisamchk in “describe mode” to produce a description of your table. 在“描述模式”下运行myisamchk以生成表的描述。If you start the MySQL server with external locking disabled, myisamchk may report an error for a table that is updated while it runs. 如果您在禁用外部锁定的情况下启动MySQL服务器,myisamchk可能会报告在运行时更新的表的错误。However, because myisamchk does not change the table in describe mode, there is no risk of destroying data.然而,由于myisamchk在描述模式下不更改表,因此没有破坏数据的风险。
Adding 添加-v
runs myisamchk in verbose mode so that it produces more information about the table. -v
会在详细模式下运行myisamchk,以便它生成有关表的更多信息。Adding 第二次添加-v
a second time produces even more information.-v
会产生更多的信息。
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.-eis
,但告诉你正在做什么。
The tbl_name
argument can be either the name of a MyISAM
table or the name of its index file, as described in Section 4.6.4, “myisamchk — MyISAM Table-Maintenance Utility”. tbl_name
参数可以是MyISAM
表的名称,也可以是其索引文件的名称,如第4.6.4节,“myisamchk-MyISAM
表维护实用程序”所述。Multiple 可以给出多个tbl_name
arguments can be given.tbl_name
参数。
Suppose that a table named 假设一个名为person
has the following structure. person
的表具有以下结构。(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.)MAX_ROWS
表选项,以便在稍后显示的myisamchk的示例输出中,一些值更小,更容易适应输出格式。)
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.MYI
Example of myisamchk -dvv output:myisamchk -dvv输出示例:
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 zeros
Explanations for the types of information myisamchk produces are given here. 这里给出了myisamchk产生的信息类型的解释。“Keyfile” refers to the index file. “Record” and “row” are synonymous, as are “field” and “column.”“Keyfile”指的是索引文件。“记录”和“行”是同义词,“字段”和“列”也是同义词
The initial part of the table description contains these values:表描述的初始部分包含以下值:
MyISAM file
Name of the MyISAM
(index) file.MyISAM
(索引)文件的名称。
Record format记录格式
The format used to store table rows. The preceding examples use 用于存储表行的格式。前面的示例使用固定长度。Fixed length
. Other possible values are 其他可能的值是Compressed
and Packed
. Compressed
(压缩)和Packed
(打包)。((Packed
corresponds to what SHOW TABLE STATUS
reports as Dynamic
.)Packed
对应于SHOW TABLE STATUS
报告为动态的内容。)
Chararacter set
The table default character set.表默认字符集。
File-version
Version of MyISAM
format. Always 1.MyISAM
格式的版本。总是1。
Creation time
When the data file was created.创建数据文件时。
Recover time
When the index/data file was last reconstructed.上次重建索引/数据文件的时间。
Status
Table status flags. Possible values are 表状态标志。可能的值包括crashed
, open
, changed
, analyzed
, optimized keys
, and sorted index pages
.crashed
、open
、changed
、analyzed
、optimized keys
和sorted index pages
。
Auto increment key
, Last value
The key number associated the table's 键号与表的AUTO_INCREMENT
column, and the most recently generated value for this column. These fields do not appear if there is no such column.AUTO_INCREMENT
列相关联,以及该列最近生成的值。如果没有这样的列,这些字段就不会出现。
Data records
The number of rows in the table.表中的行数。
Deleted blocks
How many deleted blocks still have reserved space. You can optimize your table to minimize this space. See Section 7.6.4, “MyISAM Table Optimization”.有多少已删除的块仍有保留空间。您可以优化您的表以最小化此空间。参阅第7.6.4节,“MyISAM
表优化”。
Datafile parts
For 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
.Data records
相同。
Deleted data
How many bytes of unreclaimed deleted data there are. You can optimize your table to minimize this space. See Section 7.6.4, “MyISAM Table Optimization”.有多少字节的未回收已删除数据。您可以优化您的表以最小化此空间。参阅第7.6.4节,“MyISAM表优化”。
Datafile pointer
The 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.数据文件游标的大小,以字节为单位。它通常是2、3、4或5个字节。大多数表使用2个字节进行管理,但这还不能从MySQL中控制。对于固定表,这是一个行地址。对于动态表,这是一个字节地址。
Keyfile pointer
The 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.索引文件游标的大小,以字节为单位。它通常是1、2或3个字节。大多数表使用2个字节进行管理,但这是MySQL自动计算的。它总是一个块地址。
Max datafile length
How long the table data file can become, in bytes.表数据文件的长度(以字节为单位)。
Max keyfile length
How long the table index file can become, in bytes.表索引文件的长度(以字节为单位)。
Recordlength
How 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:table description
部分包括表中所有键的列表。对于每个键,myisamchk显示一些低级信息:
Key
This 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 description
lines for the second index. This indicates that it is a multiple-part index with two parts.
Start
Where in the row this portion of the index starts.在行中,这部分索引从哪里开始。
Len
How 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 索引的这一部分有多长。对于压缩数字,这应该始终是列的全长。对于字符串,它可能比索引列的全长短,因为您可以对字符串列的前缀进行索引。多部分键的总长度是所有键部分的Len
values for all key parts.Len
值之和。
Index
Whether a key value can exist multiple times in the index. Possible values are 一个键值是否可以在索引中多次存在。可能的值是unique
or multip.
(multiple).unique
或multip
(多个)。
Type
What data type this portion of the index has. This is a 这部分索引的数据类型是什么。这是一种MyISAM
data type with the possible values packed
, stripped
, or empty
.MyISAM
数据类型,可能包含packed
、stripped
或empty
值。
Root
Address of the root index block.根索引块的地址。
Blocksize
The 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.每个索引块的大小。默认情况下,这是1024,但当MySQL从源代码构建时,该值可能会在编译时更改。
Rec/key
This 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. 这是优化器使用的统计值。它告诉这个索引的每个值有多少行。唯一索引的值始终为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.这可能会在使用myisamchk -a
加载(或大幅更改)表后更新。如果根本不更新,则给出默认值30。
The last part of the output provides information about each column:输出的最后一部分提供了有关每一列的信息:
Field
The column number.列号。
Start
The byte position of the column within table rows.表行中列的字节位置。
Length
The length of the column in bytes.列的长度(以字节为单位)。
Nullpos
, Nullbit
For columns that can be 对于可以为NULL
, MyISAM
stores NULL
values 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. NULL
的列,MyISAM
将NULL
值作为标志存储在字节中。根据有多少可以为空的列,可以有一个或多个字节用于此目的。The Nullpos
and Nullbit
values, if nonempty, indicate which byte and bit contains that flag indicating whether the column is NULL
.Nullpos
和Nullbit
值(如果非空)表示哪个字节和位包含指示列是否为NULL
的标志。
The position and number of bytes used to store 字段1的行中显示了用于存储NULL
flags is shown in the line for field 1. NULL
标志的位置和字节数。This is why there are six 这就是为什么Field
lines for the person
table even though it has only five columns.person
表只有五列,却有六行字段。
Type
The data type. The value may contain any of the following descriptors:数据类型。该值可以包含以下任何描述符:
constant
All rows have the same value.所有行都有相同的值。
no endspace
Do not store endspace.不要存储尾部空格。
no endspace, not_always
Do not store endspace and do not do endspace compression for all values.不要存储端隙,也不要对所有值进行端隙压缩。
no endspace, no empty
Do not store endspace. Do not store empty values.不要存储尾部空格。不要存储空值。
table-lookup
The column was converted to an 该列已转换为ENUM
.ENUM
。
zerofill(
N
)
The most significant 值中最重要的N
bytes in the value are always 0 and are not stored.N
个字节始终为0,不会被存储。
no zeros
Do not store zeros.不要存储零。
always zero
Zero values are stored using one bit.零值使用一位存储。
Huff tree
The number of the Huffman tree associated with the column.与该列关联的霍夫曼树的编号。
Bits
The number of bits used in the Huffman tree.霍夫曼树中使用的比特数。
The 如果表已使用myisampack压缩,则显示Huff tree
and Bits
fields are displayed if the table has been compressed with myisampack. Huff
树和Bits
字段。See Section 4.6.6, “myisampack — Generate Compressed, Read-Only MyISAM Tables”, for an example of this information.有关此信息的示例,请参阅第4.6.6节,“myisampack——生成压缩的只读MyISAM
表”。
Example of myisamchk -eiv output:myisamchk -eiv输出示例:
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:myisamchk -eiv
输出包括以下信息:
Data records
The number of rows in the table.表中的行数。
Deleted blocks
How many deleted blocks still have reserved space. You can optimize your table to minimize this space. See Section 7.6.4, “MyISAM Table Optimization”.有多少已删除的块仍有保留空间。您可以优化您的表以最小化此空间。参阅第7.6.4节,“MyISAM
表优化”。
Key
The key number.钥匙号码。
Keyblocks used
What percentage of the keyblocks are used. When a table has just been reorganized with myisamchk, the values are very high (very near theoretical maximum).使用了多少百分比的关键块。当一个表刚刚用myisamchk重新组织时,值非常高(非常接近理论最大值)。
Packed
MySQL tries to pack key values that have a common suffix. This can only be used for indexes on MySQL试图打包具有共同后缀的键值。这只能用于CHAR
and VARCHAR
columns. CHAR
和VARCHAR
列上的索引。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.对于最左侧部分相似的长索引字符串,这可以显著减少使用的空间。在前面的例子中,第二个密钥长40个字节,空间减少了97%。
Max levels
How deep the B-tree for this key is. Large tables with long key values get high values.此键的B树有多深。具有长键值的大型表会得到高值。
Records
How many rows are in the table.表中有多少行。
M.recordlength
The average row length. This is the exact row length for tables with fixed-length rows, because all rows have the same length.平均行长度。这是具有固定长度行的表的确切行长度,因为所有行的长度都相同。
Packed
MySQL strips spaces from the end of strings. The MySQL从字符串末尾删除空格。打包值表示通过这样做实现的节省百分比。Packed
value indicates the percentage of savings achieved by doing this.
Recordspace used
What percentage of the data file is used.使用了数据文件的百分比。
Empty space
What percentage of the data file is unused.数据文件中未使用的百分比是多少。
Blocks/Record
Average 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. 每行的平均块数(即一个分段行由多少个链接组成)。对于固定格式的表,此值始终为1.0。该值应尽可能接近1.0。If it gets too large, you can reorganize the table. See Section 7.6.4, “MyISAM Table Optimization”.如果它太大,你可以重新组织表格。参阅第7.6.4节,“MyISAM
表优化”。
Recordblocks
How many blocks (links) are used. For fixed-format tables, this is the same as the number of rows.使用了多少块(链接)。对于固定格式的表,这与行数相同。
Deleteblocks
How many blocks (links) are deleted.删除了多少块(链接)。
Recorddata
How many bytes in the data file are used.数据文件中使用了多少字节。
Deleted data
How many bytes in the data file are deleted (unused).数据文件中删除了多少字节(未使用)。
Lost space
If a row is updated to a shorter length, some space is lost. This is the sum of all such losses, in bytes.如果将行更新为较短的长度,则会丢失一些空间。这是所有此类损失的总和,单位为字节。
Linkdata
When the dynamic table format is used, row fragments are linked with pointers (4 to 7 bytes each). 当使用动态表格式时,行片段用游标链接(每个4到7个字节)。Linkdata
is the sum of the amount of storage used by all such pointers.Linkdata
是所有此类游标使用的存储量的总和。