Welcome Guest, Not a member yet? Register   Sign In
Can CI's database class do this? (Memory Issues w/large data sets)

I am having a memory problem because the result from the database being returned is anywhere from 5k too 100k records(and about 20 varchar255 columns +). I need to loop through each record and do a bunch of stuff but anyway the memory hit is about 25MB on only a 7,500 record return. I finally found a way to do this but I had to stop using CI's database class and use mysql function directly which I do not want to do. Why this works is because it is only taking up memory 1 record at a time and replacing that memory on the next loop, CI's database class seems to create an array looping through ALL records and then you loop through CI's array/obj. Can I use CI'S database class to only loop through 1 record at a time like below so I don't have memory problems? Basically I need CI to not create an array of all the results initially.

while ($row = mysql_fetch_assoc($result))

Thanks for the help, if you need more info let me know.


[eluser]Sarfaraz Soomro[/eluser]
Quote:Basically I need CI to not create an array of all the results initially.

First thought, you might want to run the query in a loop with limit set to 1 and offset incrementing, not a good approach IMO, maybe some one with more experience in this regard may enlighten us.

Theme © iAndrew 2016 - Forum software by © MyBB