Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    76
    Thanks
    61
    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

    Code:
    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
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 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

  • Users who have thanked BubikolRamios for this post:

    Oatley (03-26-2013)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,700
    Thanks
    80
    Thanked 4,656 Times in 4,618 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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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