Home  >  Article  >  Backend Development  >  php性能(内存)有关问题

php性能(内存)有关问题

WBOY
WBOYOriginal
2016-06-13 10:39:20718browse

php性能(内存)问题
作者:zccst

遇到这样一个问题

$retArr = array(); //数量级:十/百

其中一个字段是机型,符合条件的机型数组
$modelArr = array(); //数量级:千

其中一个字段是sn,复合体条件的sn数组
$snArr = array(); // 数量级:10万条


题意:$modelArr中有sn信息,但要判断sn是否在$snArr中,如果在,则表明复合条件;如果不在表明不符合条件(比如不在线上)。

问题:10万*1000*100 = 100亿的数据,导致内存不足。


解决办法1:使用in_array($key, $destArr);

实际运行发现内存不足。


解决办法2:结合sql查询。

可行,但需要运行1-2分钟。而前端ExtJs默认超时时间是30秒,于是更改默认超时时间为5分钟,问题解决。



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn