When running on a single server, our app can be trusted to manage its own connections - it knows how many are open and can process its internal queue as needed.
changes things. Here, many concurrent app instances are started, each unaware of the others’ connections. This can lead to a huge - potentially fatal - increase in connections straight to your DB.
External connection pools solve this by putting an additional layer between client and server, which essentially works like a message queue that gets processed as limits allow. The clients are blind to this and can keep sending their requests as before.
Navigate to Project Settings -> Database and copy your connection pool URL
Paste it into your .env file next to DATABASE_URL
Append ?schema=triggerdotdev&pgbouncer=true and insert your password
.env (excerpt)
Copy
Ask AI
...# notice the differing ports and additional query paramDATABASE_URL=postgresql://postgres:<PASSWORD>@db.<ID>.supabase.co:6543/postgres?schema=triggerdotdev&pgbouncer=trueDIRECT_URL=postgresql://postgres:<PASSWORD>@db.<ID>.supabase.co:5432/postgres?schema=triggerdotdev...
All done! You can now enjoy the benefits of connection pooling ⚡️