-
Notifications
You must be signed in to change notification settings - Fork 4
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
Batch-loader or preloading with destroy and dependent: :destroy associations N+1 problems. #25
Comments
I added Bullet, but I did not see this issue. Can you reproduce it on this project? ATM I use graphql-query-resolver supports well the nested object fields sorting - in particular sort by supplier address country, but that solution is not good for deep nested objects, see nettofarah/graphql-query-resolver#9 |
I don't know https://github.com/nettofarah/graphql-query-resolver, but what do you think about this https://github.com/ConsultingMD/graphql-preload? Is this the same problem they try to fix?
What do you think? |
I tried |
I am very confused about this subject. What's the real difference between these? |
Batch loader concept is well documented here: https://github.com/exAspArk/batch-loader#graphql-example and https://github.com/exAspArk/batch-loader#implementation-details Both of those gems use http://graphql-ruby.org/schema/lazy_execution.html The graphql-preload is simple DSL to preloaded in fields, it originates from Shopify/graphql-batch#24 (comment)
graphql-query-resolver is similar to the graphql-preload but instead of DLS it uses graphql AST to generates the associations map. Wherever loader uses Another aspects is that according to mickhansen/graphql-sequelize#316 includes are slower... but I need them for the nested sorting. I used graphql-query-resolver and includes because it created a zero configuration option that works well in the nested sorting scenario. Overall, batch loader is more flexible, faster and I should migrate to it. |
In Rails there is the
model.destroy(id)
command to delete (with callbacks) a model. Good.But when you use
dependent: :destroy
withhas_many
orhas_one
it has fun never ending with N+1 queries!!! :(Especially if I use polymorhpic associations.
See this:
As you can see gem Bullet (https://github.com/flyerhzm/bullet) detects N+1 problems...
Is there a way to handle this? Maybe with the same gem for batching and preloader? (https://github.com/Shopify/graphql-batch) - (https://github.com/ConsultingMD/graphql-preload) ?
The text was updated successfully, but these errors were encountered: