Welcome Guest, Not a member yet? Register   Sign In
Active Record large result memory exhausted
#21

[eluser]Juan Ignacio Borda[/eluser]
@CroNiX: did you ever used another abstraction layer besides the one included on CI? ADODB for example can do this same thing with less than 8mb.
ADODB or PDO will not bring your results into ram! (nor should CI)

So as pointed before, I don't having problems getting the job done, my problem is that I'm trying to do it with CI and I wanted fixed, for the all of us to use it the way we want (you can paginate or get small results if you want and I will be able to process my 1M monster table)

If you wan't i can provide a place on a public server of my own to run both tests, one with CI and one with PDO or ADODB

by the way this issue can be located at:

https://github.com/EllisLab/CodeIgniter/...nt-5661625
#22

[eluser]Unknown[/eluser]
In case anyone else comes across this problem, my solution has been to call the php mysql function directly when iterating over the result set. So we'll use CI to run the query and get the result driver object that contains the result id, then call the php mysql function directly passing the result id. I think that should allow us to process the result set using the record pointer without using CI which reads all rows into memory.


$rs = $this->db->query($sql);

while($row = mysql_fetch_array($rs->result_id)) {
....
}


#23

[eluser]Juan Ignacio Borda[/eluser]
Great practical solution doughoman, but breaks the Active Record philosophy.

[quote author="doughoman" date="1350938300"]In case anyone else comes across this problem, my solution has been to call the php mysql function directly when iterating over the result set. So we'll use CI to run the query and get the result driver object that contains the result id, then call the php mysql function directly passing the result id. I think that should allow us to process the result set using the record pointer without using CI which reads all rows into memory.


$rs = $this->db->query($sql);

while($row = mysql_fetch_array($rs->result_id)) {
....
}


[/quote]
#24

[eluser]Narf[/eluser]
CodeIgniter indeed keeps all queries in its memory, mostly for debugging purposes and profiling. If you want to change that behaviour do one of the following:

Code:
// Solution 1
$this->db->save_queries = FALSE;

// Solution 2 (database configuration)
$db['default']['save_queries'] = FALSE;

... furthermore, CodeIgniter 3 will have a new method to aid in bypassing the result caches as well:

https://github.com/EllisLab/CodeIgniter/...e39674ec7e




Theme © iAndrew 2016 - Forum software by © MyBB