-
Notifications
You must be signed in to change notification settings - Fork 66
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
Limit with DataList::filterByCallback is inconsistent. #14
Comments
I was thinking of resolving this by removing the limit from a clone of the I haven't had time to really dive into this so I'm raising it as an issue for now. |
Yes, I don't think the solution should be to just discard the limit off the original query... Whilst this shouldn't instantiate all the objects, it could load thousands, hundreds of thousands, etc of DB rows into memory only to return 10. It may be better to go through the results in chunks of 2 x limit until the limit is hit. What happens when we start introducing offset logic? For that to work properly, we always need to start from the beginning and not rely on any DB level offsets. Ultimately, the |
This gets my vote. I think time on this would be better spent elsewhere given that |
I'm happy enough with it being left as is also. I wonder if it's just worth documenting somewhere these limitations/gotchas and to consider the order of the use of this due to potential performance impact |
Documenting this as a known limitation sounds like a good idea. |
Moved to docs repo since the concensus is to update the docs. |
Affected Version: 4.9+
Description
If you call
limit
on aDataList
, and then callfilterByCallback
, the data query will first be executed, which gets a limited number of results from the database. This limited result set is then filtered using the callback, which may result in even less results being returned.This was pointed out by @christopherdarling in the below comment, which perhaps explains it a little more clearly:
Originally posted by @christopherdarling in silverstripe/silverstripe-framework#10248 (comment)
The text was updated successfully, but these errors were encountered: