I have a list of records dating back a decade. I am looking for the 25 most recent entries that include a word. The problem comes in when there aren't 25 entries, the query takes a long time to complete, as it goes through every record dating back years.
Doing a query to limit the list seems inefficient, as most queries have far more than 25 results.
I'm struggling to find the most efficient way to go about this.
What I currently am working with:
SELECT pk, title, time_item
FROM list
WHERE title LIKE '%word%' AND time_item > UNIX_TIMESTAMP() - 60*60*24*90
ORDER BY pk DESC
LIMIT 25;