View Full Version : Some help with indexing please?

03-26-2013, 01:19 PM
Hello. I am trying to understand indexing and i'm a bit stumped when it comes to joins.

I have two tables

A website table (Primary Key here is website_id)
A links table (Foreign Key here is website_id)

And every link in my links table belongs to a SINGLE website in the websites table so I perform a join on it

SELECT website.website_id, website.name, links.url
FROM links
INNER JOIN website
ON website.website_id = links.website_id

Here I have created an index on links.website_id, but when I run an EXPLAIN though for the above query it says what a possible key is (website_id) , but the columns for key and key_len are both null.

Is that correct? If not what else would I need to index everything properly here in order to run the above query? Thank you

03-26-2013, 01:44 PM
Your key (explain) is also empty. You probably have not enought data so mysql would use any key. It fugures it is best to stash everythig into memory and does not use any key.

Old Pedant
03-26-2013, 09:10 PM
Bubikol is probably right, but if you want to, you could show us what EXPLAIN shows you. There is more info in the EXPLAIN that might confirm Bubikol's guess..or not.