What's the best way to query my db?
I'm running Supabase Postgres locally with Drizzle.
In production, I'd use the connection pooler which would ensure I don't have too many concurrent connections.
I can't locally however and Supabase often gives this error:
PostgresError: remaining connection slots are reserved for non-replication superuser connections
.
I'm initiating the db as such:
And then in the necessary functions I import db and call it, like so: const database = db()
.
I have many helper functions which each create a db connection for the query, for example:
Is this the right way of doing things? Or should I pass the database to the helper functions, instead of initiating a connection there?
I want to ensure I'm not creating unnecessary connections to the DB. Are there any best practices I should be aware of?
Thanks!3 Replies