Home > database >  Mysql two table don't use the index
Mysql two table don't use the index

Time:09-27

Two tables test_a, test_b structure and index information as follows, by primary key inner join associations, appearance index of why don't you go?
 
The create table test_a (
Id int,
Birthday date is not null,
The comment varchar (50) not null,
Primary key test_a_pk (id),
The index test_a_index (birthday)
) engine=innodb default charset=utf8;

The create table test_b (
Id int,
Salary is double the not null,
Struct varchar (50) not null,
Primary key test_b_pk (id),
The index test_b_index (salary)
) engine=innodb default charset=utf8;

mysql> Show the index from test_a \ G
* * * * * * * * * * * * * * * * * * * * * * * * * * * 1 row * * * * * * * * * * * * * * * * * * * * * * * * * * *
Table: test_a
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: id
Collation: A
Cardinality: 5375084
Sub_part: NULL
The Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
* * * * * * * * * * * * * * * * * * * * * * * * * * * 2. Row * * * * * * * * * * * * * * * * * * * * * * * * * * *
Table: test_a
Non_unique: 1
Key_name: test_a_index
Seq_in_index: 1
Column_name: birthday
Collation: A
Cardinality: 2728
Sub_part: NULL
The Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
2 rows in the set (0.00 SEC)

mysql> Show the index from test_b \ G
* * * * * * * * * * * * * * * * * * * * * * * * * * * 1 row * * * * * * * * * * * * * * * * * * * * * * * * * * *
Table: test_b
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: id
Collation: A
Cardinality: 5291561
Sub_part: NULL
The Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
* * * * * * * * * * * * * * * * * * * * * * * * * * * 2. Row * * * * * * * * * * * * * * * * * * * * * * * * * * *
Table: test_b
Non_unique: 1
Key_name: test_b_index
Seq_in_index: 1
Column_name: salary
Collation: A
Cardinality: 943640
Sub_part: NULL
The Packed: NULL
Null:
Index_type: BTREE
Comment:
Index_comment:
2 rows in the set (0.00 SEC)


  • Related