와 indices 지금까지 내가 우리의 코드는 모든 인덱스, 아직 몇 가지 정보를 사용하여 말할 수불필요한 MySQL은 우리가 꽤 큰 것으로부터 우리의 데이터베이스에있는 우리의 테이블 중 하나가
show index from entries;
+---------+------------+----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+---------+------------+----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| entries | 0 | PRIMARY | 1 | id | A | 13538389 | NULL | NULL | | BTREE | |
| entries | 0 | index_entries_on_link_and_feed_id | 1 | link | A | 13538389 | NULL | NULL | YES | BTREE | |
| entries | 0 | index_entries_on_link_and_feed_id | 2 | feed_id | A | 13538389 | NULL | NULL | YES | BTREE | |
| entries | 0 | index_entries_on_unique_id_and_feed_id | 1 | unique_id | A | 13538389 | NULL | NULL | YES | BTREE | |
| entries | 0 | index_entries_on_unique_id_and_feed_id | 2 | feed_id | A | 13538389 | NULL | NULL | YES | BTREE | |
| entries | 1 | index_entries_on_feed_id | 1 | feed_id | A | 81556 | NULL | NULL | YES | BTREE | |
| entries | 1 | index_entries_on_time | 1 | time | A | 967027 | NULL | NULL | YES | BTREE | |
| entries | 1 | index_entries_on_created_at | 1 | created_at | A | 846149 | NULL | NULL | YES | BTREE | |
+---------+------------+----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
8 rows in set (1.35 sec)
:
/그래서 내가 인덱스를 보여 주었다 : 데이터 자체로 거의 두 배 크다 중복 될 수 있습니다 : index_entries_on_feed_id
은 index_entries_on_link_and_feed_id
및 index_entries_on_unique_id_and_feed_id
모두 사용하기 때문에 색인이 중복 될 수 있습니다.
맞습니까?
feed_id가 순서대로 첫 번째 필드가 아니기 때문에 MySQL에서 * 다른 * 색인을 사용하지 않을 것으로 기대합니다. 인덱스가 때때로 데이터보다 많은 공간을 차지한다는 것에 놀랄 필요는 없습니다. – Joe
흥미 롭습니다. 즉, index_entries_on_link_and_feed_id 또는 index_entries_on_unique_id_and_feed_id 중 하나에서 순서를 변경하면 index_entries_on_feed_id 인덱스가 필요하지 않습니까? –