MySQL中索引資訊說明
檢視索引
show index from student;
Table |
Non_unique |
Key_name |
Seq_in_index |
Column_name |
Collation |
Cardinality |
Sub_part |
Packed |
Null |
Index_type |
Comment |
Index_comment |
Visible |
Expression |
student |
0 |
PRIMARY |
1 |
id |
A |
167722 |
BTREE |
YES |
||||||
student |
1 |
idx_student_class_id |
1 |
class_id |
A |
2984 |
YES |
BTREE |
YES |
|||||
student |
1 |
idx_student_school_id |
1 |
school_id |
A |
262 |
YES |
BTREE |
YES |
|||||
student |
1 |
idx_student_area |
1 |
area |
A |
64 |
YES |
BTREE |
YES |
|||||
student |
1 |
idx_student_city |
1 |
city |
A |
9 |
YES |
BTREE |
YES |
|||||
student |
1 |
idx_student_province |
1 |
province |
A |
1 |
YES |
BTREE |
YES |
|||||
student |
1 |
idx_student_exclude |
1 |
exclude |
A |
1 |
BTREE |
YES |
||||||
student |
1 |
idx_student_subject_group |
1 |
subject_group |
A |
11 |
YES |
BTREE |
YES |
|||||
student |
1 |
idx_student_subject_ids |
1 |
subject_ids |
A |
82 |
YES |
BTREE |
YES |
索引資訊中的列的資訊說明。
Table :表的名稱。
Non_unique:如果索引不能包括重複詞,則為0。如果可以,則為1。
Key_name:索引的名稱。
Seq_in_index:索引中的列序列號,從1開始。
Column_name:列名稱。
Collation:列以什麼方式儲存在索引中。在MySQLSHOW INDEX語法中,有值'A'(升序)或NULL(無分類)。
Cardinality:索引中唯一值的數目的估計值。通過執行ANALYZE TABLE或myisamchk -a可以更新。基數根據被儲存為整數的統計資料來計數,所以即使對於小型表,該值也沒有必要是精確的。基數越大,當進行聯合時,MySQL使用該索引的機會就越大。
Sub_part:如果列只是被部分地編入索引,則為被編入索引的字元的數目。如果整列被編入索引,則為NULL。
Packed:指示關鍵字如何被壓縮。如果沒有被壓縮,則為NULL。
Null:如果列含有NULL,則含有YES。如果沒有,則為空。
Index_type:儲存索引資料結構方法(BTREE, FULLTEXT, HASH, RTREE)