This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-30
Channels
- # announcements (2)
- # babashka (37)
- # beginners (64)
- # biff (27)
- # cherry (7)
- # cider (19)
- # clj-kondo (10)
- # clojure-austin (4)
- # clojure-doc (18)
- # clojure-europe (72)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (5)
- # clojurescript (18)
- # data-science (28)
- # events (5)
- # graalvm (32)
- # hyperfiddle (6)
- # introduce-yourself (1)
- # jobs (4)
- # joyride (16)
- # juxt (6)
- # malli (7)
- # missionary (3)
- # off-topic (18)
- # pathom (15)
- # portal (14)
- # re-frame (14)
- # reitit (5)
- # releases (1)
- # rum (2)
- # sci (1)
- # shadow-cljs (102)
- # spacemacs (3)
- # sql (6)
- # web-security (2)
- # xtdb (10)
What is happening here? I have a resolver that returns a list of users, but when it returns 1000s of users it takes a long time because it looks like each user is processed sequentially. Is there a way to do it in parallel / faster?
If you’re using Pathom3, try turning that into a https://pathom3.wsscode.com/docs/resolvers/#batch-resolvers
@U3XCG2GBZ it's a resolvers that returns a collections of users, output is {:admin/users [:user/id]} and there is no subquery needed to resolve further. this little green blocks seem to be purely pathom processing the outputs
marking the result as pco/final does remove these but ofc it's not suitable if eg I want extra attributes that are not resolved immediately by this resolver which is the case for a bunch of other queries that I have that do return a big amount of items in a seq
If it’s consuming time on simply processing the data (and not fetching from a db or something) then I’m not too sure. If you’re trying to take a large number of entities and process them by filtering or aggregating, doing that work db side will almost always be better option as apposed to using Pathom. Pathom just doesn’t have the performance for that sort of task.
However, if it’s just a data fetching problem you’re trying to speed up, your {:admin/users [:user/id]}
should work just fine, and you’ll want to turn your user/id
-> user/name, ...
resolver into a batch resolver.
Also try out the p.a.eql/parallel?
option and see if that helps.
Make sure you’re using the p.a.eql
too, and not p.eql
resolvers you want running in parallel should return futures or promises or whatever
I didn’t know about ::pco/final
. That’s pretty handy
hello Eric, yeah, this is an overhead that pathom adds because even if the entity has all the data, Pathom must check it (scan over results, compare the data with required query, etc...)
if you know you wont have any futher process, you can use ::pco/final
to mark the data as complete, doing so will tell pathom to not try anything, this way you can avoid the scan
I was thinking the parallle processor could try to split a vector in blocks and process them in parallel, but its tricky, because I also dont want to be spawing too many threads, a solution like that involves also adding some sort of thread management/configuration
@U066U8JQJ would it be possible to have something like “final” but instead of doing nothing it does the job on the first item of the sequence and extrapolates to all the others? Because when the resolvers is getting a lot of rows from a table you are 100% sure all items have the same shape of outputs?
not impossible, but its a considerable change, something maybe to test and see if there are enough gains to compensate the add complexity