Comments (6)
That will respect the limit better, but it would not be performant as it's still fetching (and presumably instantiating) all records from the database.
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 filterByCallback
method is always going to be crude and, as datasets get large, be completely unreliable as a method for filtering large sets. I think we have two choices, one of which is just to leave it as it is and have it be a known limitation of the feature, or we improve it but provide lots of guidance/warnings about how it really shouldn't be used for any large sized datasets.
from developer-docs.
I think we have two choices, one of which is just to leave it as it is and have it be a known limitation of the feature
This gets my vote. I think time on this would be better spent elsewhere given that filterByCallback()
is a bit of an anti-pattern
from developer-docs.
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
from developer-docs.
Documenting this as a known limitation sounds like a good idea.
from developer-docs.
I was thinking of resolving this by removing the limit from a clone of the DataList
prior to running the callback filter loop, and then breaking the loop once we have the limit number of items. That will respect the limit better, but it would not be performant as it's still fetching (and presumably instantiating) all records from the database.
I haven't had time to really dive into this so I'm raising it as an issue for now.
from developer-docs.
Moved to docs repo since the concensus is to update the docs.
from developer-docs.
Related Issues (20)
- Delete docs about RFC process - or start following the process again HOT 6
- Add silverstripe/dynamodb as a supported module for CMS 5 HOT 2
- Add extra details CMS 5.1 changelog HOT 3
- Code sample needs to return $validator HOT 1
- Encourage use of `shuffle()` instead of `orderBy()` HOT 1
- Review our OSS contribution doc HOT 5
- Small doc problems to be fixed HOT 1
- Smarter publication state is documented
- Add linting for custom markdown syntax
- Add linting for language structure/style
- Review best practice docs for JS and CSS
- Document nested request handlers HOT 1
- Add method signatures to definition of public API HOT 1
- Review contribution Maintainer Guideline following the initial onboarding first crop of maintainers
- Typo in linting rule options HOT 1
- Document current approach to creating API endpoints in the CMS HOT 2
- Add docs for generic lazy loading feature HOT 1
- "Environment Types" docs section not found. HOT 1
- Fix spelling error
- Provide guidance on "Programmatically creating a file" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from developer-docs.