-
-
Notifications
You must be signed in to change notification settings - Fork 475
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
Significantly reduce number of db connection in flex output #2134
Conversation
This way prepared statements are different and we can have several of them in the same connection. We'll use that in the future.
Each table of the flex output kept its own database connection in the table_connection_t class. With this change, the connection is kept in a vector in the flex output instead. This is a refactoring step towards using fewer database connections. As long as each table had its own connection, we can not reduce them, but if we keep them outside, we will be able to re-use the same connection for different tables.
Most operations are not run in parallel anyway, they only need a single connection. For the parts running in parallel, we have one connection per thread. We don't have connections for each table any more.
Wonderful! I'll try to test this out soon. This might remove my motivation behind trying to get pgbouncer to work. 😆 |
This works well in the initial load. Before the patch I get 41 idle connections on my default load, this change drops it to 3 idle. 👍 I ran into an error when using
|
The error you are getting is probably not related to this change but to an earlier change (PR #2115). Can you run with debugging so that we can see what command |
It looks like the error was in my code running
It works if I take off the second |
@rustprooflabs As I had suspected, that is due to #2115. We are a bit more picky in checking the command line options. We'll put a warning in the release notes. |
Flex outputs uses a lot of connections, basically O(number of threads * number of tables). They are mostly idle but need resources on the server. And the PostgreSQL default max number of connections is often not large enough.
With these changes the number of connections is much smaller, connections are not open for such long a time.
There is probably more we can do here, closing some connections earlier or so. But this is a big step solving most of the problem.