Reputation: 11580
Few basic doubts I have:
1. Is primary key column automatically indexed?
2. What should be criteria to select index column?
3. When should I club multiple columns?
4. Does MyISAM or InnoDB has any affect on which columns should be indexed? Probably not.
5. Are they really required, specially in case if primary key column is automatically indexed?
Thanks.
Upvotes: 2
Views: 268
Reputation: 157828
The indexing is quite complex job.
First, it should be done based on the real needs. If some of your query turns to run slow, it's time to add some indexes. If your query runs fast, no index needed.
Next, run your query with word EXPLAIN
in front of it, e.g. EXPLAIN SELECT * FROM table
and see what it says. Usually it helps to determine, where to place an idnex.
http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html - more explanations here
Upvotes: 1