#In NextJS, do we have to use is it best practise attachDatabasePool(pool) combined with PrismaORM?

1 messages · Page 1 of 1 (latest)

visual forumBOT
#

Hi @bright escarp. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

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 PrismaClient instance (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 call attachDatabasePool(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 (like pg.Pool) on Fluid Compute.
  • For Prisma ORM, the documented best practice is to use a shared PrismaClient instance; there is no explicit guidance in these sources to wrap Prisma with attachDatabasePool.
#

If you’re only using Prisma (no manual pg/mysql2 pool), the knowledge sources do not say you must or should add attachDatabasePool.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: