2 ms·
In my experience the dataloader approach is simpler once you need even a modest amount of logic to decide what should be loaded. Basically a dynamic vs. static
by tveita 6y ago
In my experience the dataloader approach is simpler once you need even a modest amount of logic to decide what should be loaded. Basically a dynamic vs. static scheduling decision.
E.g. you have IDs for a heterogeneous collection of items, all of them have an owning user, some need additional lookups in type specific tables, some have comments which again have an attached user each. Each lookup should be done towards a cache like Memcached and then a SQL database for any entries not in cache.
If you want to batch those cache calls together as best possible you end up with some fairly ugly code.
But with dataloader you can write nice and sequential code dealing with a single item at a time - try loading the item from cache, if not try the database, if found load related data, if not return not found.