-
Notifications
You must be signed in to change notification settings - Fork 861
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
Describe - alternative to Prepare for PgBouncer and 1 round trip queries #558
Comments
any postgresql documentation for what you're describing, I'm curious and interested. =) |
https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY -- in particular the unnamed prepared statement and the describe message. The PostgreSQL protocol supports one round trip extended query just fine. The trick is that with pgx we want to use the binary format when possible. But we need to do a describe to know the types of the response values to know if we can interpret the binary format so when not using a prepared statement it typically takes 2 round trips. But we also can't use prepared statements with PgBouncer. So that leaves falling back to the simple protocol. Currently a normal non-prepared query is executed by pgx as follows: Step 1:
Step 2:
PgBouncer is free to send step 1 and 2 to different backends because of the I'm picturing something like this would solve it: Step 1:
Step 2:
We end up |
I've implemented described statement caching (#559). This makes it trivial to use PgBouncer with the extended protocol. |
@jackc could you elaborate if there is anything one needs to configure in order to use it with PgBouncer in transaction pool mode? |
Connect with |
@jackc would you consider |
No, it is not. |
Thanks for the precision. So to recap for anyone looking for this information. If you have an app that need to support live schema changes (e.g. a database migration):
|
We can prepare the unnamed prepared statement to get a description of the query text. That description could be used to send a query with the extended protocol in a single round trip. This could improve performance in some cases and it would should the extended protocol usable with PgBouncer even in statement mode.
The text was updated successfully, but these errors were encountered: