There is already a primary key index on ID.
From: Wm Mussatto [mailto:mussatto@stripped]
Sent: Tuesday, April 01, 2008 10:50 AM
Subject: Re: Indices in InnoDB/MySQL
On Tue, April 1, 2008 10:01, Robert DiFalco wrote:
> I've been told that an index always contains the primary key. So if I
> have a LONG ID that is the primary key of table and create on index on
> LONG VALUE, the index on LONG VALUE will actually work as a typical
> compound index on ID,VALUE. My question is this, if I don't know that
> about MySQL and create my indices on purpose (i.e. not taking into
> account implementation details about MySQL) I would create the index
> explicitly on ID,VALUE. If I did that would I effectively have the
> same index as one on just VALUE or would there some how be duplicate
> data in the ID,VALUE index (i.e. ID, ID, VALUE)?
Close but not quite there...
You should always have AN index which is the primary key. You can
create other indexes which don't. If you are searching for 'Value' then
that should be the index. If you do ID,VALUE it can't use the index
AFAIK because it won't know the ID.
William R. Mussatto
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql