小编Zmr*_*zka的帖子

mysqli_fetch_assoc()性能PHP5.4 vs PHP7.0

我有大量的MySQL查询(1.8M行,25列),我需要从中创建二维数组(基于主键的内存表).

代码按预期工作,但$ table创建在PHP7.0中需要很长时间.

PHP7.0表现如此糟糕的原因是什么?我的主要兴趣在于mysqli.

感谢您的任何见解 - 如果我可以修复性能,PHP7会为我节省大量内存.

mysqli代码片段

$start = microtime(true);

$vysledek = cluster::query("SELECT * FROM `table` WHERE 1");
$query_time = (microtime(true) - $start);
$start_fetch = microtime(true);
while($zaznam = mysqli_fetch_assoc ( $vysledek )){
  $fetch_time+= (microtime(true) - $start_fetch);
  $start_assign = microtime(true);
  $table[$zaznam['prikey']] = $zaznam;
  $assign_time+= (microtime(true) - $start_assign);
  $start_fetch = microtime(true);
}
$total_time+= (microtime(true) - $start);
echo round($assign_time, 2).' seconds to set the array values\n';
echo round($query_time, 2).' seconds to execute the query\n';
echo round($fetch_time, 2).' seconds to fetch data\n'; …
Run Code Online (Sandbox Code Playgroud)

php mysql performance mysqli multidimensional-array

19
推荐指数
1
解决办法
1412
查看次数

标签 统计

multidimensional-array ×1

mysql ×1

mysqli ×1

performance ×1

php ×1