Recently during the Swedish MySQL User Group (SMUG), I presented
a session dedicated to MySQL InnoDB Primary Keys.
I forgot to mention a detail that many people are not aware, but
Jeremy Cole has pointed out.
Primary Key always included in secondary indexes at the
right-most column
When we define a secondary index, the secondary index includes
the Primary Key as the right-most column of the index. It’s
silently added, meaning that it’s not visible but it’s used to
point back to the record in the clustered index.
This is an example with a table having a Primary Key composed of
multiple columns:
CREATE TABLE `t1` (
`a` int NOT NULL,
`b` int NOT NULL,
`c` int NOT NULL,
`d` int NOT NULL,
`e` int …
[Read more]