-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there an example of pooling connections using pq ? #21
Comments
database/sql keeps an idle pool. If there is no connection when a request is made, it creates a new one. If the pool is full when the connection is free, it throws it away. On May 25, 2012, at 12:38 PM, Constantin Teodorescureply@reply.github.com wrote:
|
It sounds great but ... are there any fine tunings for pool size like "minimum of opened connections", "maximum of opened connections", "timeout for closing an unused connection" ? I searched for more detail but the golang package doc isn't too clear regarding that. |
It's currently hard coded at two. I haven't needed to tune it myself. If you have more questions regarding database/sql, I recommend asking then on the gonuts mailing list where it's authors can help you more. Pq specific questions can be made here. On May 25, 2012, at 1:02 PM, Constantin Teodorescureply@reply.github.com wrote:
|
OK, I'll ask there and dig a little into the database/sql code to find out! |
I want to use pq in a middleware program that will serve more than 100 web clients simultaneously and it's possible to need a pool of 10 or 20 active connections to a PostgreSQL database and pool the connections between goroutines serving different web rest-services.
Is there an example how to do that using your pq driver?
In the golang docs there is something written about "database/sql" package:
"If the underlying database driver has the concept of a connection and per-connection session state, the sql package manages creating and freeing connections automatically, including maintaining a free pool of idle connections. "
Best regards,
Constantin Teodorescu
The text was updated successfully, but these errors were encountered: