N
Neon2y ago
xenial-black

Should PrismaNeon adapter use pooler URL?

Following the example code here:
import { Pool, neonConfig } from '@neondatabase/serverless'
import { PrismaNeon } from '@prisma/adapter-neon'
import { PrismaClient } from '@prisma/client'
import dotenv from 'dotenv'
import ws from 'ws'

dotenv.config()
neonConfig.webSocketConstructor = ws
const connectionString = `${process.env.DATABASE_URL}`

const pool = new Pool({ connectionString })
const adapter = new PrismaNeon(pool)
const prisma = new PrismaClient({ adapter })
import { Pool, neonConfig } from '@neondatabase/serverless'
import { PrismaNeon } from '@prisma/adapter-neon'
import { PrismaClient } from '@prisma/client'
import dotenv from 'dotenv'
import ws from 'ws'

dotenv.config()
neonConfig.webSocketConstructor = ws
const connectionString = `${process.env.DATABASE_URL}`

const pool = new Pool({ connectionString })
const adapter = new PrismaNeon(pool)
const prisma = new PrismaClient({ adapter })
Should process.env.DATABASE_URL be set to the pooler URL or the direct URL? Does using the adapter make the pooler unnecessary? Same question applies when using in Cloudflare.
5 Replies
rare-sapphire
rare-sapphire2y ago
For most use cases you should use the pooler
passive-yellow
passive-yellow2y ago
As Tristan says, you should generally use the pooler URL to prevent your application(s) from potentially exhausting your Postgres instance connection limits. Using the non-pooler URL is sometimes necessary for performing schema migrations.
xenial-black
xenial-blackOP2y ago
@Tristan Partin @ShinyPokemon thanks for the response! I figured that was the case. But I was looking at the new Cloudflare docs (https://neon.tech/docs/guides/cloudflare-workers) and the example URL used there was not a pooler URL, so it got me second-guessing myself...
Neon
Use Neon with Cloudflare Workers - Neon Docs
Cloudflare Workers is a serverless platform allowing you to deploy your applications globally across Cloudflare's network. It supports running JavaScript, TypeScript, and WebAssembly, making it a grea...
rare-sapphire
rare-sapphire2y ago
@Daniel any reason we don't recommend the pooled url there?
equal-aqua
equal-aqua2y ago
That should be a pooled URL, I think. We'll update that.

Did you find this page helpful?