3 ms·
I haven't had a chance to dig into dataloaders much. Is the basic idea you perform one query per "layer?" Maybe not as great as just using something like A.obje
by yeswecatan 6y ago
I haven't had a chance to dig into dataloaders much. Is the basic idea you perform one query per "layer?" Maybe not as great as just using something like A.objects.prefetch_related(related_objects__other_object), but better than N+1
- Ozzie_osman 6y ago(Sorry for the delay here) At face value, it can issue one more query per layer, but you get a lot of other benefits by breaking down your logic in this way. For example, you're less inclined to use database joins that may not scale as you grow. Another benefit is that you can very easily switch storage layers. For instance, maybe you fetch one layer from your SQL database, and another from a KV store database. Or maybe one layer comes from the cache, etc.