I have a big list of domain names, and a big list of words. I want to check how many domain names in my list have each of these words at the end of them. I tried 2 queries but both are taking too much time to execute. Trying to find out if there is any way to make the query faster.
First I tried this query, it is taking around 50 minutes to return results:
SELECT COUNT(*) AS count
FROM table
WHERE domain_name LIKE '%my_word.%';
Then I thought maybe if I remove the .%
from it, maybe it would go faster so I tried this, but it is still slow:
SELECT COUNT(*) AS count
FROM table
WHERE SUBSTRING_INDEX(domain_name, '.', 1) LIKE '%my_word';
Anyone has an idea of a query that might go faster?
Thanks.