Why tb1.Name=tb2.Name does not use index on Name

Reply

Join Date: Sep 2008
Posts: 15
Reputation: cy163 is an unknown quantity at this point 
Solved Threads: 0
cy163 cy163 is offline Offline
Newbie Poster

Why tb1.Name=tb2.Name does not use index on Name

 
0
  #1
Nov 5th, 2008
Hello ALL,

I did the following query. the EXPLAIN result showed 'NULL' in the 'key' colume, meaning that NONE of indexes have been used. However, indexes have been created on Name fields for both tb1 and tb2. I wonder why MySQL does not use the indexes to speed up the query. Is there any way to make the query faster?



  1.  
  2.  
  3. EXPLAIN SELECT
  4. tb1.Name
  5. FROM
  6. tb1, tb2
  7. WHERE
  8. tb1.Name = tb2.Name;
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Why tb1.Name=tb2.Name does not use index on Name

 
0
  #2
Nov 5th, 2008
are you using a foreign key on the name column?
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 79
Reputation: varmadba is an unknown quantity at this point 
Solved Threads: 8
varmadba varmadba is offline Offline
Junior Poster in Training

Re: Why tb1.Name=tb2.Name does not use index on Name

 
0
  #3
Nov 5th, 2008
See if you force mysql to use index

  1. EXPLAIN SELECT
  2. tb1.Name
  3. FROM
  4. tb1, tb2 FORCE index(t1.name)
  5. WHERE
  6. tb1.Name = tb2.Name;

and also check it name column is of same data type in both the tables
:- Varma

We are Happy to inform launch of a new site with loads of database related information Site offers wide range of functionality Forums,Blogs,Articles,Editorials and much more
http://www.sqllibrarian.info/
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC