I have a script that when a user searches for “Apples”, there is a coloumn with related searches like “Shiny Apples”, and “Rotten Apples”, etc.
Problem is my searches database has 5,600,000 rows and mysql is lagging very badly.
Here is my code:
$get = mysql_query("SELECT keyword FROM searches WHERE MATCH (keyword) AGAINST ('".mysql_real_escape_string(preg_replace('#([\S]+)#', '$1', $title))."' IN BOOLEAN MODE) LIMIT 0,15");
This is taking a very long time to process and I have a very active website where searches are getting performed every second, can anybody recommend me some tips?
Thanks!
You need indexes. I have had some experiences in the past where just by creating indexes we got significant performance gain.