Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2013, 11:18 AM   PM User | #1
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
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 ?
__________________
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

Last edited by BubikolRamios; 01-04-2013 at 11:52 AM..
BubikolRamios is offline   Reply With Quote
Old 01-04-2013, 07:46 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,188
Thanks: 59
Thanked 3,995 Times in 3,964 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 01-04-2013, 08:14 PM   PM User | #3
BubikolRamios
Senior Coder

 
Join Date: Dec 2005
Location: Slovenia
Posts: 1,876
Thanks: 114
Thanked 76 Times in 76 Posts
BubikolRamios is on a distinguished road
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
BubikolRamios is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:42 AM.


Advertisement
Log in to turn off these ads.