I am still getting my head around MySQL INDEXES… A quick question…
I have a table that stores a members location. It has a member_id and location_id columns… I do a MySQL query to find all the locations for a specific member…
Would it be better to setup an INDEX like this:
ALTER TABLE `members_locations` ADD INDEX `member_location` ( `member_id` , `location_id` )
Or should I separate them like this>
ALTER TABLE `members_locations` ADD INDEX `member_id` ( `member_id` );
ALTER TABLE `members_locations` ADD INDEX `location_id` ( `location_id` );
Does it make any difference?
This article should be helpful.
Here’s an example from it:
ALTER TABLE buyers ADD INDEX idx_name_age(first_name,last_name,age);
Here’s another article showing the difference between using a multi-column index and several single-column indexes.