We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Allowed memory exhausted

Hello,

Im trying to fetch all the users in my Model by doing a simple Users::find() and I keep on getting a fatal error, Allowed memory exhausted, I have 512MB, which I believe should be sufficient, it shouldn't need more.

Other feches on smaller tables return results, so it's a problem of the size of the result fetched.



16.4k

How big is the table?



3.1k

It has 65.000 rows, it also happens to me when I fetch in a model with 16.000 rows, it doesnt when I fetch smaller ones.

2015-02-26 2:58 GMT+01:00 Max Castro [email protected]:

How big is the table?

— Reply to this email directly or view the complete thread on Phosphorum https://forum.phalcon.io/discussion/6022/allowed-memory-exhausted#C16187. Change your e-mail preferences here https://forum.phalcon.io/settings

-- David Shaikh Urbina Mobile: (+34) 647 727 132 Mail: [email protected] Web: www.wasabiappfactory.com

This email and its attached files are confidential. Any kind of distribution or publication of its content is not allowed and needs the prior consent of Wasabi App Factory SL. Advertencia/Confidentiality Notice https://www.wasabiappfactory.com/advertenciaconfidentiality-notice/



16.4k

Yeah, but how big in megas is the tables? also paste the code plz.

Thanks



8.1k

This is a feature of PDO driver PHP.

You can use sparing algorithms.

Or use msqli driver.

See : https://forum.phalcon.io/discussion/3793/phalcon-resultsets-and-large-mysql-tables



3.1k

It's 1.57GB, I didnt realise how big it was.

The code is a simple $usersNewbies = Users::find();, you need something more?

Yeah, but how big in megas is the tables? also paste the code plz.

Thanks

— Reply to this email directly or view the complete thread on Phosphorum https://forum.phalcon.io/discussion/6022/allowed-memory-exhausted#C16196. Change your e-mail preferences here https://forum.phalcon.io/settings

-- David Shaikh Urbina Mobile: (+34) 647 727 132 Mail: [email protected] Web: www.wasabiappfactory.com

This email and its attached files are confidential. Any kind of distribution or publication of its content is not allowed and needs the prior consent of Wasabi App Factory SL. Advertencia/Confidentiality Notice https://www.wasabiappfactory.com/advertenciaconfidentiality-notice/



16.4k

@subhard did @Oleg suggestion work?



3.1k

Changing to mysqli wasnt an option for us.

I tried several ways, and apparently using Users::find(); involves bringing all the data from the table and that uses all the memory when it's a big table. I suposed phalcon would optimize that. Using Users::find(array("columns" => idUser)); made the query faster and it didnt use all the memory. But I ended up using Depency Injector and mysql querys, which are very fast and also don't use up all the memory.