Question regarding MySQL indices and their functionality

Posted by user281434 on Stack Overflow See other posts from Stack Overflow or by user281434
Published on 2010-03-18T16:28:19Z Indexed on 2010/03/18 16:31 UTC
Read the original article Hit count: 267

Filed under:
|

Hi

Say I have an ordinary table in my db like so

----------------------------
| id | username | password |
----------------------------
| 24 | blah     | blah     |
----------------------------

A primary key is assigned to the id column. Now when I run a Mysql query like this:

SELECT id FROM table WHERE username = 'blah' LIMIT 1

Does that primary key index even help? If I am telling it to match usernames, then shouldn't the username column be indexed instead?

Thanks for your time

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php