List:General Discussion« Previous MessageNext Message »
From:Jeremy Chase Date:January 30 2013 7:25pm
Subject:InnoDB interaction between secondary and primary keys.
View as plain text  
 Hello,

I've been working with a secondary index and would like some clarification
about how the primary columns are included. So, in the following example,
is the secondaryKey effectively the same as redundantKey?

CREATE TABLE `example` (
  `1` int(10) unsigned NOT NULL,
  `2` int(10) unsigned NOT NULL,
  `3` int(10) unsigned NOT NULL,
  `4` int(10) unsigned NOT NULL,
  PRIMARY KEY (`1`,`2`),
  KEY `secondaryKey` (`3`, `4`)
  KEY `redundantKey` (`3`, `4`, `1`, `2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Background: http://dev.mysql.com/doc/refman/5.5/en/innodb-index-types.html

"In InnoDB, each record in a secondary index contains the primary key
columns for the row, as well as the columns specified for the secondary
index."

Thank you!
Jeremy

Thread
InnoDB interaction between secondary and primary keys.Jeremy Chase30 Jan
  • RE: InnoDB interaction between secondary and primary keys.Rick James30 Jan
  • RE: InnoDB interaction between secondary and primary keys.Rick James30 Jan
    • Re: InnoDB interaction between secondary and primary keys.Jeremy Chase1 Feb