By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

Should I add a multi column index to MySQL?

P: n/a
Hello,

I have a mysql table. Two columns in the table are used to pull out
stories from the table.

One of the columns stands for categories of the stories, and the other
column is the primary key and has the id for each story.

I am thinking of writing queries like this:

mysql_query("SELECT * FROM articles WHERE category='Science_Fiction'
AND story_id='45'");

I am wondering if I should create a multi column index that covers both
"categories" and "story_id" columns. -- INDEX (categories, story_id)

Would this increase performance?

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
mudge wrote:
Hello,

I have a mysql table. Two columns in the table are used to pull out
stories from the table.

One of the columns stands for categories of the stories, and the other
column is the primary key and has the id for each story.

I am thinking of writing queries like this:

mysql_query("SELECT * FROM articles WHERE category='Science_Fiction'
AND story_id='45'");

I am wondering if I should create a multi column index that covers both
"categories" and "story_id" columns. -- INDEX (categories, story_id)

Would this increase performance?


Your query should return the same results as

SELECT * FROM articles WHERE story_id='45';

because story_id is the primary key.

Primary keys always have an index, so the answer is no.
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.