Do Prisma resolve N+1 problem?

prisma

#1

Do Prisma resolve N+1 problem?
E.g. I take 100 users with their friends, for example. Will it optimize queries (make 2 and combine data or use joins)? Or it will run 101 query?


#2

Hi,

Prisma will load data efficiently in those cases (2 queries). Prisma has a data loader that will first fetch the users with one query and will then make a deferred pass to fetch all friends.

Cheers.


#3

thank you! great news)


#4

Thanks for bringing up this question, @Terion :slightly_smiling_face:

I agree with what you said on Slack - this should be part of our documentation. I’d be happy to review a PR that adds a respective section.

Thanks :raised_hands: