Should I add a multi column index to MySQL?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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?

Re: Should I add a multi column index to MySQL?

mudge wrote:
Quoted text here. Click to load it

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.

Site Timeline