![]() |
DB inserts & Memory not cleared? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: DB inserts & Memory not cleared? (/showthread.php?tid=12732) |
DB inserts & Memory not cleared? - El Forum - 10-29-2008 [eluser]J3roen[/eluser] I encountered a problem when inserting lot's of data in a mysql database. The memory used keeps increasing every insert query, for some reason it saves some data somewhere? Shouldn't it clear the data after every insert? Using version 1.7. To reproduce: Code: CREATE TABLE `yourdatabase`.`test` ( Code: <? Produces: Code: 2.8 DB inserts & Memory not cleared? - El Forum - 10-29-2008 [eluser]J3roen[/eluser] Pure PHP example: Code: <? In this case the memory usage stays the same and does not grow. DB inserts & Memory not cleared? - El Forum - 10-29-2008 [eluser]J3roen[/eluser] :red: it seems codeigniter is caching every query by default in the database class. For large amounts of data this results in a lot of overhead. Solution: $this->db->save_queries = false; May be good idea to add this to the documentation? I couldn't find it myself in the documentation. Figured it out by doing a print_r on the database object. Why is CI actually caching the queries? DB inserts & Memory not cleared? - El Forum - 11-05-2008 [eluser]Naki[/eluser] Thank you very much! I had the same problem and your solution works fine ^^ |