Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts

    Some help with indexing please?

    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
    Last edited by Oatley; 03-26-2013 at 01:23 PM.

  2. #2
    Senior Coder
    Join Date
    Dec 2005
    Thanked 79 Times in 79 Posts
    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.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  3. Users who have thanked BubikolRamios for this post:

    Oatley (03-26-2013)

  4. #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    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.
    Be yourself. No one else is as qualified.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts