PrismaP
Prisma13mo ago
3 replies
overthinkerrrr

Significant Performance Gap: Prisma vs Supabase Client in Nuxt 3

Issue Description


I've built a performance comparison tool to test the response times between Prisma and Supabase client when querying the same Supabase database. The results show that Prisma queries are significantly slower (approximately 7-8x) than direct Supabase client queries.

Environment


- Nuxt 3
- Prisma
- @nuxtjs/supabase
- Database: PostgreSQL - Supabase
- Connection: Using Supabase connection pooling (Supavisor)

Code Snippet


- Prisma
import prisma from '~/lib/prisma'

export default defineEventHandler(async () => {
    const courses = await prisma.courses.findMany({
        where: {
            coursegroup: 'XXXX'
        },
        select: {
            coursecode: true
        }
    })
    return { 
        courses: courses.map(course => course.coursecode)
    }
}) 

- SupabaseClient
import { serverSupabaseClient } from '#supabase/server'

export default defineEventHandler(async (event) => {
  const client = await serverSupabaseClient(event)
  const { data: courses, error } = await client
    .from('Courses')
    .select('coursecode')
    .eq('coursegroup', 'XXXX')

  return { courses }
})


Questions


- Why is there such a significant performance difference between Prisma and Supabase client?
- Are there any recommended configurations or optimizations for Prisma when used with Supabase?
- Could this be related to connection pooling or the way Prisma establishes database connections?
- Are there any best practices for improving Prisma's performance in this scenario?

Additional Context


- No significant load on the database
- Both implementations use the same database connection string with connection pooling
- The performance difference is consistent across multiple tests
image.png
Was this page helpful?