Hi I have like 2000 users in my system. I would like to get a count of the active ones, so I did it like this:


but this returns the count with the limit of 100, so when I remove the limit


I got this error

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /Users/alex/git/website/craft/app/models/BaseModel.php on line 280

2 Answers 2


Use .total() instead of .count()

.count() will query the db and fetch all fields for all items relating to your criteria and then count them.

.total() only counts the number of items your criteria returns without all of their fields.


In addition to Luke's answer, you might want to consider bumping your php.ini file's memory_limit to something higher than 128M, like 256M.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.