Jump to content
xisto Community
vizskywalker

MySQL Indexes

Recommended Posts

I've been searching the MySQL documentatiopn, but I can't seem to find exactly what purpose indexes serve. I have a database that needs to be searchale by practically every column, and I don't know whether everything needs to be indexed, and if so how. Any information on the imprtance of indexes, and perhaps a small explanantion of the different kinds would be appreciated.Thanks~Viz

Share this post


Link to post
Share on other sites

Indexes are they way the database accesses the single recond you need. If I need to know something about vizskywalker, if I have an index on "name", I do a single disk access to read the index, and the index tells me where to do the second disk access to have the info concerning vizskywalker. If I have no index, I will have to read the whole database everytime I want the info concerning vizskywalker. So, from a philosophy point of view, if you want to read the whole database everytime you want to display something on your screen, you need no index. If you want to read the enfo concerning somebody (vizskywalker for instance) and only this info, you need an index.So, if you want to have fast access to your data when asking for a name, you need to create an index on the "name" column. If you want to retrieve records concerning year of birth, the index has to be created on the year column. If you never do queries concerning "studies and hobbies", do not index the column named "studies_and_hobbies".hope this helped.Yordan

Share this post


Link to post
Share on other sites

So, query wise, how does a search for the record pertaining to 'yordan' vary depending on whether or not I have an index? I know without an index it would be:

SELECT * FROM <table> WHERE `name`='yordan'
(At least I think there are quotes around yordan.)

~Viz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.