Mysql全文search导致CPU使用率高
我们build了一个新闻网站。 我们每天都会从web apiinput数以万计的数据。 为了提供精确的search服务,我们的表使用MyISAM,build立全文索引(标题,内容,date)。 我们的网站现在在Godaddy VDS上testing,2GB内存,30GB空间(无交换,因为VDS不允许交换)。 使用#grep “model name” /proc/cpuinfo我们得到Godaddy使用Intel(R) Xeon(R) CPU L5609 @ 1.87GHz 这里是我们的mysqlinput,使用FROM dual避免插入重复logging,并且表的FULLTEXT索引始终打开。 INSERT INTO newstable (title,link,content,date,source,image,imagesource) SELECT '".$title."','".$link."','','".$content."','".$date."','".$source."','".$image."','".$imagesource."' FROM dual WHERE not exists (SELECT content FROM newstable WHERE newstable.content = '".$content."') 这里是我们的search查询在阅读页面(我们已经优化了主页,这是一个静态页面,从crond生成,但阅读页面应该保持在实时search): SELECT id,title,link,content,date,source,image,imagesource FROM newstable WHERE (MATCH (title,content,date) AGAINST ('$boolean' IN BOOLEAN MODE)) Order By date DESC Limit '.($_POST['number']).', […]