Skip to content

Pipeline mode for Pool #3738

Description

@nigrosimone

pipeline: true works on a Client but a Pool cannot use it. pool.query() checks a client out, runs one query on it and gives it back only when the result arrives, so there is never a second query on that connection to pipeline with. Passing pipeline: true to the Pool config changes nothing today.

postgres.js already does this automatically. It keeps the connections in three groups:

  • idle
  • busy but still accepting
  • full
    when nothing is idle it sends the query on a busy one.

It limits itself with a depth cap (max_pipeline, default 100), with the socket backpressure, and it refuses to pipeline cursors.

The same is possible here and the public API almost does not change:

const pool = new Pool({ max: 10, pipeline: true, maxPipeline: 100 })
await pool.query('SELECT $1::int', [1]) // same call, can go on a connection already working

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions