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
    2,022
    Thanks
    120
    Thanked 77 Times in 77 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
    29,353
    Thanks
    83
    Thanked 4,904 Times in 4,865 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.
    Be yourself. No one else is as qualified.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    2,022
    Thanks
    120
    Thanked 77 Times in 77 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
    •