-
-
Notifications
You must be signed in to change notification settings - Fork 457
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
Question: Why prepare statement requires extra round-trip? #1212
Comments
Yep, that's the reason. You can use query_typed to bypass this if you need to, but if you're that concerned about perf you should probably be preparing the statements up front and reusing them across requests. |
Thanks @sfackler . Regarding the query_typed API, is it safe for pipelining and does it guarantee order of execution? Asking because I believe it uses unnamed statements, and I'm not sure how that interacts in a pipeline. I also came across #930 which is a couple years older, but it seemed the consensus was that order of execution was only guaranteed if the statement was prepared up front. Does that still apply for query_typed? |
thanks @sfackler What would be the best way to achieve jdbc's batch behavior (multiple prepared statements with separate bindings but all in one round trip).
At the moment, I've got something like this
The only gap I'm seeing is that if the Is there any mechanism by which I could force statements after a failure to be discarded? Is the only way for pipelined queries to be followed by a single Sync message instead of a Sync per statement? |
Hi all,
I'm a newbie to rust coming from a java background. I've been doing some comparisons between tokio-postgres and the postgres jdbc driver and was curious about some of the differences I saw.
One difference was that it seemed the postges Parse message was requiring an extra round trip whereas in jdbc, the parse/bind/execute messages are inline. Here's an example captured packet for the latter:
I'm curious, what are the differences between the rust and jdbc driver implementations where the latter eliminates the extra round-trip. So far, the only thing I can tell is the rust implementation looks at the prepared statement output during the Bind phase. e.g. when making sure the caller passes the expected number of inputs:
rust-postgres/tokio-postgres/src/query.rs
Line 234 in 1e1f6bf
Thanks!
The text was updated successfully, but these errors were encountered: