mysql join on two indexes takes long time!!
- by Alaa
Hi All
I have a custom query in dripal, this query is:
select count(distinct B.src)
from node A, url_alias B
where concat('node/',A.nid)= B.src;
now, nid in node is primary key and i have made src as an index in url_alias table.
after waiting for more than a minute i got this:
+-----------------------+
| count(distinct B.src) |
+-----------------------+
| 325715 |
+-----------------------+
1 row in set (1 min 24.37 sec)
now my question is: why did this query take this long, and how to optimize it??
Thanks for your help