No, just don't do it.
Instead of iterating over 10,000 elements, it’s better to extract the words from the sentence or text, then add it to the SQL query, and thus you will have all the necessary entries. This is certainly more effective than the solution you offer.
You can do this as follows using PHP:
$possible_keywords = preg_split('/\b/', $your_text, PREG_SPLIT_NO_EMPTY);
The above will split the text at word boundaries and will not return any empty elements to the array.
Then you can simply create the SQL query as shown below:
SELECT * FROM `keywords` WHERE `keywords`.`keyword` IN (...)
(just put a list of extracted words in parenthesis)
You should probably filter the $possible_keywords array before making a query (include only keywords with the appropriate length and exclude duplicates), and also index the keyword columns.
source share