mysql - Should I add the Primary Key to a Secondary index with InnoDB? -
for example have table:
| id | name | age |
id
primary key;
this query:
select id table age > 12 order id desc
is necessary append id
index, as:
key idx (age, id)
or index enough?
key idx (age)
ps: i'm using innodb storage engine.
from docs
in innodb, each record in secondary index contains primary key columns row, columns specified secondary index.
so no, assuming id
primary key table
, present on secondary (non-clustered) indexes well, i.e. add age
index.
Comments
Post a Comment