Performance of deeply nested ctx.db.exists calls

prisma

#1

If I’m using deeply nested ctx.db.exists calls with Prisma Bindings on my graphql-server, how computationally expensive are they? I’ve outlined three examples which are three to four nodes deep.

Example 1 - Two nodes away

const requestingUserEditAccess = await ctx.db.exists.Book({
    id: id,
    library: {
      libraryAccesses_some: {
        access_in: ["EDIT", "ADMIN"],
        user: { id: userId }
      }
    }
  })

Example 2 - Three nodes away

   const requestingUserEditAccess = await ctx.db.exists.PageOfBook({
        id: id,
        book: {
           library: {
             libraryAccesses_some: {
                 access_in: ["EDIT", "ADMIN"],
                 user: { id: userId }
              }
           }
        }
      })

Example 3 - Three nodes away with an OR statement

   const requestingUserEditAccess = await ctx.db.exists.PageOfBook({
        id: id,
        book: {
           OR: [{
             library: {
               libraryAccesses_some: {
                 access_in: ["EDIT", "ADMIN"],
                 user: { id: userId }
              }
            }
          },{
            book: {
              bookAccesses_some: {
                access_in: ["EDIT", "ADMIN"],
                user: { id: userId }
              }
            }
          }]
        }
      })

#2

I have no idea. I’d fire up Apache Bench and knock the hell out of it :slight_smile:

I’m curious what the SQL implementation is.