MYSQL query not using multiple column index

I have a multiple column index on a mysql table. Let's say the index is (first, second, third). When I run this query

SELECT first, second, third
FROM table

EXPLAIN shows me it is using the index. But if I run the following query

SELECT first, second, third, fourth
FROM table

it is not using the index.

Do I need all the columns that I am selecting to be in the index?
spectrumcareAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
No but there is no reason to use the index to just SELECT fields.  If you use ORDER BY the indexed fields, then it should use the index.
0
 
spectrumcareAuthor Commented:
Sorry, I am using  order by FIRST. But for whatever reason, it is not using the index if I try to query a field that is not included in the index. I've even tried forcing the index.
0
 
spectrumcareAuthor Commented:
Could the issue be that I have an autonumber column that is forced to have a primary index on it?
0
 
spectrumcareAuthor Commented:
I've got it working now. I'll give you the points for answering.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.