Fork me on GitHub
#pathom
<
2024-05-09
>
Lidor Cohen06:05:02

Hi everyone 👋 I came across this claim in the docs of smart maps: > Preload data > If you know the attributes you will need ahead of time, it's more efficient to load then in a single run than fetching one by one lazily. > Does anyone know the reason behind this claim? If the results are cached during lookup why is it more efficient to calculate them ahead of time? I'm guessing it's still runtime (i.e no compile-time like macro expansion), and the amount of work to be done is the same. Maybe it means you can do it ahead of time if you have idle time and that would be more efficient use of your time?

Linus Ericsson07:05:41

This is likely an advice based on implementation, but resolvers in pathom are either returning several attributes or just one each. When a smart map is used, it is likely better to resolve all the attributes at once, because multiple calls could resolve all attributes several times.

favila11:05:12

Besides that, a plan could be more optimal of it knows all of what you need, plus the plan itself needs to be calculated (and can be cached), plus batch resolvers can’t be used, etc