Giter Site home page Giter Site logo

Comments (6)

dhensby avatar dhensby commented on June 27, 2024 1

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.

kinglozzer avatar kinglozzer commented on June 27, 2024 1

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.

christopherdarling avatar christopherdarling commented on June 27, 2024 1

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.

GuySartorelli avatar GuySartorelli commented on June 27, 2024 1

Documenting this as a known limitation sounds like a good idea.

from developer-docs.

GuySartorelli avatar GuySartorelli commented on June 27, 2024

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.

GuySartorelli avatar GuySartorelli commented on June 27, 2024

Moved to docs repo since the concensus is to update the docs.

from developer-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.