Indexes and multi column primary keys
Posted
by David Jenings
on Stack Overflow
See other posts from Stack Overflow
or by David Jenings
Published on 2010-06-15T18:55:03Z
Indexed on
2010/06/15
19:02 UTC
Read the original article
Hit count: 239
Went searching and didn't find the answer to this specific noob question. My apologies if I missed it.
In a MySQL database I have a table with the following primary key
PRIMARY KEY id (invoice, item)
In my application I will also frequently be selecting on "item" by itself and less frequently on only "invoice". I'm assuming I would benefit from indexes on these columns.
MySQL does not complain when I define the following:
INDEX (invoice), INDEX (item), PRIMARY KEY id (invoice, item)
But I don't see any evidence (using DESCRIBE -- the only way I know how to look) that separate indexes have been established for these two columns.
So the question is, are the columns that make up a primary key automatically indexed individually? Also, is there a better way than DESCRIBE to explore the structure of my table?
© Stack Overflow or respective owner