List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 1 2008 5:58pm
Subject:Re: Indices in InnoDB/MySQL
View as plain text  
At 10:01 AM -0700 4/1/08, Robert DiFalco wrote:
>I've been told that an index always contains the primary key.

By who?

Ask for proof.


>  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)?

I'm not exactly sure what you're asking, but if I understand correctly,
the answer is no.

You might find these sections of the manual helpful:

http://dev.mysql.com/doc/refman/5.0/en/indexes.html
http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Thread
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