php - Iterate mysqli unbuffered query result more than once -


problem:

i have query returns large result set. large bring php. fatal memory max error , cannot increase memory limit. unbuffered queries

i need iterate on array multiple times mysqli_data_seek doesn't work on unbuffered queries. mysqli_result::data_seek

//i have buffered result set $bresult = $mysql->query("select * small_table");  //and large unbuffered result set $uresult = $mysqli->query("select * big_table", mysqli_use_result);  //the join combine them takes long , large //the result set returned unbuffered query large store in php //there many rows in $bresult re-execute query or subset of each 1  foreach($bresult &$row) {     //my solution search $uresult foreach row in $bresult values need     $row['x'] = searchresult($uresult, $row['key']);     //problem: after first search, $uresult @ , and cannot reset mysqli_result::data_seek }  function searchresult($uresult, $val)     while($row = $uresult->fetch_assoc()){         if($row['x'] == $val) {             return $row['x'];         }     } } 

if have solution meets these requirements accept it: - not try join result in single query (takes long) - not run query each result in query (too many queries, takes long, slows down system)

please leave comment if need more info.

thank you.

if you're trying process big data set have considered using intermediary hadoop? can set small hadoop cluster, processing, have php code make request processed data hadoop output.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -