Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Running out of memory when doing find()

I have a table that contains 120,000+ records and when I do MyModel::find() on it, PHP is running out of memory. I assume it is reading the entire result set and creating model instances for each. But, according to the Phalcon documentation:

"One of the greatest features of the Phalcon\Mvc\Model\Resultset is that at any time there is only one record in memory. This greatly helps in memory management especially when working with large amounts of data."

Am I misunderstanding how the Resultset works? Is there a setting I need to set to get the Resultset to handle this? I am using MySQL.


I understand what my problem was now. Resultset works fine. The problem was that I was using the Resultset in a paginator which was causing the Resultset to load everything in an array. This link discusses it and the new QueryBuilder paginator that works differently: