Matt Pocock
07/28/2021, 11:32 AMMichał K
07/28/2021, 1:06 PMimport { PrismaClient } from '@prisma/client'
let prisma: PrismaClient
const g = global as any
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient()
} else {
if (!g.prisma) {
g.prisma = new PrismaClient()
}
prisma = g.prisma
}
export default prisma
are u sure u are using the same client isntead of invoking the new one each time?Daniel Norman
client_idle_timeout
) to drop idle client connections. By default it’s disabled.
• Calling prisma.$disconnect
at the end of a Lambda functions. This should reduce the number of idle connections, however it comes at the cost of the connection overhead to PgBouncer when a warm function is reused and has to re-establish a connection to PgBouncer.