SELECT T1.name AS hotel,
T2.name AS city
FROM (SELECT *
FROM hotel
WHERE name LIKE '$term1%') T1,
(SELECT *
FROM city
WHERE name LIKE '$term2%') T2
WHERE T1.city_id = T2.id
T1 has 150,000, T2 has 15,000. (Static tables!) I have indexes for the "name" for these tables.
Is there a way to optimize this mysql query? I also want to do → LIKE '% term1%', but very slowly.
source
share