Code Monkey home page Code Monkey logo

Comments (6)

gabivlj avatar gabivlj commented on May 29, 2024 1

We don’t want multiple queries to mongodb when we can do a single one.

from chat-it-app.

gabivlj avatar gabivlj commented on May 29, 2024

The problem will be present because when you want for example a post with comments inside, you will make a query for each post, and we don’t want that, that will happen in Mongo, Postgresql, any DB... There is dataloader because we don’t want to make a lot of mongo queries, just make a single one and gather all the data we need.

from chat-it-app.

gabivlj avatar gabivlj commented on May 29, 2024

We don’t want multiple queries to mongodb when we can do a single one.

Just to clarify, is it the fact that graphql is causing the "n+1" problem even though the db is mongodb. However, some say mongodb won't have "n+1" problem, what's the point for that?
Thanks

Can you link the people that say that? Maybe they do another method for batching inside the same request , but the way that it works without dataloader is that it will call the resolvers and make a lot of database lookups.

from chat-it-app.

kockok avatar kockok commented on May 29, 2024

We don’t want multiple queries to mongodb when we can do a single one.

Just to clarify, is it the fact that graphql is causing the "n+1" problem even though the db is mongodb. However, some say mongodb won't have "n+1" problem, what's the point for that?
Thanks

Can you link the people that say that? Maybe they do another method for batching inside the same request , but the way that it works without dataloader is that it will call the resolvers and make a lot of database lookups.

I'm thrilled by your reply.
I asked a similar question on stackoverflow and got downvotes.
Screenshot 2020-06-29 at 12 41 25 AM

And recently got baffled by the relationship between the n+1 thing and nosql.

from chat-it-app.

gabivlj avatar gabivlj commented on May 29, 2024

Basically, if you have a relationship between collections and you wanna add data from another collection you might encounter a n+1 problem when using Graphql and gathering data the way I said before. That usually happens in every db that can have this kind of relationship, but it’s more common to see it in relational ones because they are more effective doing join operations and things like that.

from chat-it-app.

kockok avatar kockok commented on May 29, 2024

Basically, if you have a relationship between collections and you wanna add data from another collection you might encounter a n+1 problem when using Graphql and gathering data the way I said before. That usually happens in every db that can have this kind of relationship, but it’s more common to see it in relational ones because they are more effective doing join operations and things like that.

Thank you so much for your thorough reply indeed.

from chat-it-app.

Related Issues (2)

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.