#database connections, one or multiple?

3 messages · Page 1 of 1 (latest)

torpid trellis
#

If you're using sql.DB, you're already opening many connections. sql.DB is a connection pooler, not a single connection.

#

So yes, "open" one at the start and reuse it throughout your application. If a connection is already in use by another goroutine, it'll spawn a new connection. And reuse those connections in future, returning them to the pool once they're no longer in use.