-
Notifications
You must be signed in to change notification settings - Fork 234
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 a connection pool for postgresql? #671
Comments
What should I do quickly with multithreading,if not use connection pool, |
Depending on how you manage the work in your threads (i.e. if one thread is only ever doing one thing at a time) then you could use a |
To begin with, there are TCP timeout and connection timeout limits. If a thread accesses the connection pool many times, the cost of acquiring a lock may exceed the cost of connection creation. The only thing that connection pooling will definitely improve is the total number of connections to the database server. If you know that the max number of connections to the database is a small number, you should adopt connection pooling. |
There's also a couple of connection pool implementations that sit between your application and the database, for example pgpool and pgbouncer. These are applications that specialise in this one task and means you don't have to even have to think about the pooling. |
Exactly. This is why libpqxx doesn't have connection pooling built in. You can combine libpqxx with a connection pool. A pool may want to do asynchronous housekeeping, which to me feels like an uncomfortable fit for a library. |
I suppose we can close this now. |
I will use libpqxx for my web server with multithreading,and I want to reduce the overhead of database connections.
Is there a API connection pool for postgresql?
The text was updated successfully, but these errors were encountered: