@kian @elithrar @AJR Thanks for your responses. Is there a document that describes the pooling mech

@kian @elithrar @AJR Thanks for your responses.

Is there a document that describes the pooling mechanism? I am particularly interested in how prepared statements behave if I make two identical queries.

let res1 = client.query("SELECT * FROM FOO", &[]).await?;
let res2 = client.query("SELECT * FROM FOO", &[]).await?;


Would the statement prepared in the first query be cached? In other words, would Hyperdrive call prepare twice (as in https://github.com/sfackler/rust-postgres/blob/98f5a11bc0a8e451552d8941ffa078c7eb6cd60c/tokio-postgres/src/to_statement.rs#L18, which is invoked from https://github.com/sfackler/rust-postgres/blob/98f5a11bc0a8e451552d8941ffa078c7eb6cd60c/tokio-postgres/src/client.rs#L363.

A bit of context:

I am in the process of supporting Cloudflare Worker for Exograph (https://github.com/exograph/exograph/pull/1081). It is working okay without Hyperdrive (high latency) and great with Hyperdrive (with a fork of tokio-postgres to avoid prepared statements: https://github.com/sfackler/rust-postgres/pull/1147).

I would like to determine the extent of Hyperdrive support to decide if there is value in continuing to use my fork. For example, if Hyperdrive reuses the prepared statement, then going with query will be better (to be measured, of course). If not, my fork avoids an extra roundtrip.
Was this page helpful?