Skip to content

How does this work with pipelining? #280

Closed Answered by bikeshedder
feelingsonice asked this question in Q&A
Discussion options

You must be logged in to vote

You can perform pipelining with connections from tokio-postgres regardless if you create the connection manually or get them from the pool.

There are two use cases:

  • One worker issues two (or more) queries at the same time using a single connection.
    This works just as explained in the tokio-postgres documentation:

    async fn pipelined_prepare(
        client: &Client,
    ) -> Result<(Statement, Statement), Error>
    {
        future::try_join(
            client.prepare("SELECT * FROM foo"),
            client.prepare("INSERT INTO bar (id, name) VALUES ($1, $2)")
        ).await
    }
  • Two (or more) workers sharing a single connection and using pipelining that way.
    This requires a different way to think about pooled…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bikeshedder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
A-postgres Area: PostgreSQL support / deadpool-postgres
2 participants