List:General Discussion« Previous MessageNext Message »
From:Robert DiFalco Date:April 1 2008 6:19pm
Subject:RE: Indices in InnoDB/MySQL
View as plain text  
There is already a primary key index on ID. 

-----Original Message-----
From: Wm Mussatto [mailto:mussatto@stripped] 
Sent: Tuesday, April 01, 2008 10:50 AM
To: mysql@stripped
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)?
> R.
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
Systems Engineer

MySQL General Mailing List
For list archives:
To unsubscribe:

Indices in InnoDB/MySQLRobert DiFalco1 Apr
  • Re: Indices in InnoDB/MySQLBaron Schwartz7 Apr
Re: Indices in InnoDB/MySQLWm Mussatto1 Apr
  • RE: Indices in InnoDB/MySQLRobert DiFalco1 Apr
Re: Indices in InnoDB/MySQLPaul DuBois1 Apr