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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -