I need some help trying to improve the speed of my script. Heres the two queries..
$sql = "SELECT PadID FROM keywords WHERE Word = '$search'";
$sql = "SELECT Category, LongCategory, PageBase, PageName, ProgramName,
ProgramVersion, English250, ReleaseDate, License
FROM pads
LEFT JOIN categories ON pads.CatID = categories.CatID
WHERE PadID IN ($pads)
ORDER BY VersionAddDate DESC
LIMIT $variable,20";
The first query produced a list of PadId’s which I use a parameter in the second query.
This works find most of the time, however, if I get a call for a very popular keywords the script can take several seconds to run. This morning I had a keyword with 9600 records.
What can I do to fix it.
EDIT: The problem is my site has been scraped this morning, had several thousand calls within a 20 minutes. However the second query takes a few seconds with that many records anyway, so I need to improve it.
9600 returned records is heavy to load AND neither a helpful search result. (who browses more than five google-search-pages?)
Narrowing down the RS to 1% would make more sense, consider adding “weight” based on popularity, date etc.
For best performance, use composite indexes (highest uniqueness).