-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Affected Rows in Collection for counting #1280
Comments
Trying to count 20k objects in memory is a bad idea. It's better to run a separate query with the same conditions explicitly to get the count. |
Should |
As @nateabele said, for your use case it's best to use a count query. You never want that many records in a result set at once. At one point you'll start processing them in some way. I agree with @shopblocks that Collection could be optimized in a way: create a FixedCollection that allows us to pass a count manually, which will be returned by it instead of looking at it's items. The count would come from http://php.net/manual/de/pdostatement.rowcount.php and the MongoDB equivalent. |
Thats fine, we have changed our code to have a |
Performing a count on a RecordSet is very memory intensive.
Performing a count on 20,000 rows using
I can see that it uses the
util/Collection
class, which implementscount
like this:I believe the slowness is caused by the
iterator_count
call, which loops over all of the records.How come something like this can't be done:
A quick way to recreate the memory issues is to do the following:
The text was updated successfully, but these errors were encountered: