我有一个包含 800 万行的表,需要针对大量的坏词进行扫描。
我的第一个想法是:
UPDATE `master` SET `blacklisted`='1' WHERE MATCH (`content-desc`, `content-title`) AGAINST ('
badword1 | badword2 | badword3 | "and many more"' IN BOOLEAN MODE)
不幸的是,这个版本忘记了一些单词并且不区分大小写!
下一次尝试是
$badwords = array("badword1","badword2","badword3","and-many-more");
foreach($badwords AS $name)
{
$sql = "UPDATE `master` SET `blacklisted`='1' WHERE concat(`content-title(mediumtext)`,`content-desc(mediumtext)`) LIKE '%".$name."%'";
sleep(6);
// Could limit this query by 100.000 and adding another foreach loop help?
// How would the foreach look like (select count(*) from master?)/100.000
}
很多查询立即杀死了我的服务器!也许评论的想法会有所帮助?!(但是怎么做?)
谁有最好的想法如何解决这个查询,而不会给 mysql 服务器带来太多压力?谢谢!