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?

EXPLAIN SELECT
         tb1.Name
FROM
         tb1, tb2
WHERE
         tb1.Name = tb2.Name;

Recommended Answers

All 2 Replies

are you using a foreign key on the name column?

See if you force mysql to use index

EXPLAIN SELECT
         tb1.Name
FROM
         tb1, tb2 force index(t1.name)
WHERE
         tb1.Name = tb2.Name;

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.