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

Thread: use of index

  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts

    use of index

    Code:
    Select *
    from galery_1 g left join tezaver t on g.id_tezaver = t.id_tezaver and t.l2 = 'la'

    Code:
    "id","select_type","table","type","possible_keys","key","key_len","ref","rows","Extra"
    "1","SIMPLE","g","ALL",(Null),(Null)(Null)(Null),"8099",""
    "1","SIMPLE","t","ref","id_l2,Index_3","id_l2","16","test.g.id_tezaver,const","1",""
    If I remove 'left' from query

    Code:
    "id","select_type","table","type","possible_keys","key","key_len","ref","rows","Extra"
    "1","SIMPLE","g","ALL","Index_2",\N,\N,\N,"8099",""
    "1","SIMPLE","t","ref","id_l2,Index_3","id_l2","16","test.g.id_tezaver,const","1","Using where"
    So I get possible index, which is not used.

    Code:
    Index_2(id_tezaver)
     id_l2(id_tezaver,la)
    Any suggestion ?

    Furthermore, if I use 'FORCE INDEX (index_2)' or 'USE INDEX (index_2), should that reflect in EXPLAIN result, coz it looks like it don't ?
    Last edited by BubikolRamios; 01-04-2013 at 11:52 AM.
    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

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,843
    Thanks
    78
    Thanked 4,414 Times in 4,379 Posts
    If MySQL decides that using a key won't help performance, then it will be very stubborn about it. There's not much you can do to force it to use the keys.

    With only 8099 rows involved, MySQL undoubtedly feels that just loading the entire table into memory will be better than using the index.
    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.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Thanks.
    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


  •  

    Posting Permissions

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