#In NextJS, do we have to use is it best practise attachDatabasePool(pool) combined with PrismaORM?
1 messages · Page 1 of 1 (latest)
You do not have to use attachDatabasePool(pool) with Prisma in Next.js, and the provided knowledge sources do not state that this is a best practice specifically for Prisma.
What the docs do say:
- For Prisma + Postgres in Next.js, the recommended pattern is to create a single
PrismaClientinstance (with a global singleton in development) and import it where needed. [Prisma client setup] - For relational databases in general (using drivers like
pg,mysql2, etc.) on Vercel Functions with Fluid Compute, the recommendation is to create a connection pool and callattachDatabasePool(pool)to manage idle connections and pooling efficiently. [Connection pooling guide; attachDatabasePool]
However, none of the sources explicitly describe using attachDatabasePool with Prisma’s own connection management, nor do they show an example of combining them. Prisma typically manages its own connections based on the datasource configuration (e.g. pooled vs direct URLs). [Prisma schema with pooled URLs]
So, based on the available docs:
attachDatabasePool(pool)is a best practice for driver-level pools (likepg.Pool) on Fluid Compute.- For Prisma ORM, the documented best practice is to use a shared
PrismaClientinstance; there is no explicit guidance in these sources to wrap Prisma withattachDatabasePool.