943,578 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 596
  • MySQL RSS
Nov 5th, 2008
0

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

Expand Post »
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?



MySQL Syntax (Toggle Plain Text)
  1.  
  2.  
  3. EXPLAIN SELECT
  4. tb1.Name
  5. FROM
  6. tb1, tb2
  7. WHERE
  8. tb1.Name = tb2.Name;
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cy163 is offline Offline
16 posts
since Sep 2008
Nov 5th, 2008
0

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

are you using a foreign key on the name column?
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Nov 5th, 2008
0

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

See if you force mysql to use index

MySQL Syntax (Toggle Plain Text)
  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
Reputation Points: 22
Solved Threads: 9
Junior Poster in Training
varmadba is offline Offline
83 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC