0
我有一个代码,我从数据库中获取域并通过PHP getmxrr函数传递它们。然后我将结果存储在数据库中。但是这个过程非常缓慢。有什么方法可以加快速度吗?速度php getmxrr()函数处理百万条记录
$stmt = $link->prepare($sql);
$stmt->execute();
$row = $stmt->fetchAll();
foreach ($row as $value) {
$domain = $value[0];
//getmxrr doesn't work without this
$string = preg_replace('/\s+/','',$domain);
if (getmxrr($string,$mxrecords)){
if(isset($mxrecords[0])){
$mx = $mxrecords[0];} else $mx = "False";
}
else{
$mx = "NULL";
}
$stmt1->execute(); //inserting the results in DB
}
您处理了多少条记录?你可以定义“慢”,你确定它不是很慢的MySQL吗? –
我假设问题是DNS请求的持续时间。尝试使用不同的(更好的缓存)DNS服务器来加速重复发出的请求。 – Stasik
从慢我的意思是每秒约1-2个请求。 @RyanNaddy – tgarg