Slow dataloader resolvers in Absinthe

I’m running into what looks like a performance issue with Absinthe Dataloader. In addition to using dataloader for vanilla field resolution from ecto, I’m also using run_batch/5 as a way to efficiently compute aggregate values for nested fields (think having a field friends_count on entity Profile, and retrieving a list of profiles… you want to run a single query to get all the counts).

Looking through NewRelic, I’m seeing individual field resolution calls take 100ms+:

This may either be an instrumentation issue, or my lack of understanding, but I expected there to be a single db call per aggregate (which is the case on sql side) and then fast resolution since they’re just map lookups. Are the resolvers just awaiting the db call and then all running in parallel? Or is something else going on?

By any chance are these resolutions happening as part of a subscription? There’s some documentation about this kind of problem with subscriptions: Understanding Subscriptions — absinthe v1.6.5

nope, just straight query

The resolution time shown for a given resolver is the time from the moment the batch is initiated until the time it has the result from the batch. You can see that those times are all parallel. What this lengthy time implies though is that the batch itself is slow. I would see if you can get some telemetry on the SQL query its running.

Got it, thanks. That was my hunch but wanted to confirm that’s how it worked.