問題:
大きな結果セットを返すクエリがあります。PHP に取り込むには大きすぎます。致命的なメモリ最大エラーが発生し、メモリ制限を増やすことができません。バッファリングされていないクエリ
配列を複数回反復する必要がありますが、mysqli_data_seek はバッファリングされていないクエリでは機能しません。mysqli_result::data_seek
//I have a buffered result set
$bresult = $mysql->query("SELECT * FROM Small_Table");
//And a very large unbuffered result set
$uresult = $mysqli->query("SELECT * FROM Big_Table", MYSQLI_USE_RESULT);
//The join to combine them takes too long and is too large
//The result set returned by the unbuffered query is too large itself to store in PHP
//There are too many rows in $bresult to re-execute the query or even a subset of it for each one
foreach($bresult as &$row) {
//My solution was to search $uresult foreach row in $bresult to get the values I need
$row['X'] = searchResult($uresult, $row['Key']);
//PROBLEM: After the first search, $uresult is at its and and cannot be reset with mysqli_result::data_seek
}
function searchResult($uresult, $val)
while($row = $uresult->fetch_assoc()){
if($row['X'] == $val) {
return $row['X'];
}
}
}
これらの要件を満たす別のソリューションがある場合は、それを受け入れます: - 単一のクエリで結果を結合しようとしない (時間がかかりすぎる) - 別のクエリで結果ごとにクエリを実行しない (クエリが多すぎる、時間がかかりすぎる)長く、システムが遅くなります)
さらに情報が必要な場合は、コメントを残してください。
ありがとうございました。