Answer the question
In order to leave comments, you need to log in
How do you deal with postgresql connection pooling in GO?
Greetings!
How to work with connection pools for postgre in GO, how to organize a permanent connection and is it necessary? What kind? sqlx pgx? How to get a free connection from the pool?
Answer the question
In order to leave comments, you need to log in
database.sql.DB from stdlib does not transparently maintain connection pooling under the hood. Methods are proposed for pool management
DB.SetMaxOpenConns
DB.SetMaxIdleConns
DB.SetConnMaxLifetime
db.BeginTx
, a free connection from the pool is selected for it. conn, err := Db.Conn(context)
conn.BeginTx
on this connection. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question