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
- SupabaseClient
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
3 Replies
You chose to debug with a human. They'll tinker with your query soon. If you get curious meanwhile, hop into
#ask-ai
for a quick spin!:heart: any comment is appreciate
Hey 👋
Apologies for the delay in responding to this question!
Currently, Prisma internally uses Rust-based query engine which handles generating SQL, running migrations, and mapping records to JavaScript/TypeScript objects. This extra translation and runtime can add overhead compared to directly using the Supabase (or raw PostgreSQL) client.
(On a side note, we are working on moving this logic from Rust to TS to improve performance. More details here)
Can you check if you get the same performance behaviour with a raw sql query?