Skip to content

Support for pipelining #59

@stephenh

Description

@stephenh

Is your feature request related to a problem? Please describe.

Pipelining allows a txn to send all of its INSERTs/UPDATEs/DELETEs "simultaneously" without waiting for responses to each one. This can lead to ~3-6x perf increases, depending on the data/benchmark:

https://joist-orm.io/blog/initial-pipelining-benchmark/

Describe the solution you'd like

A way to have multiple queries issued, and then awaitd via Promise.all, like:

bench("pipeline Promise.all", async () => {
  await sql.begin(async (sql) => {
    const statements = [];
    for (let i = 0; i < numStatements; i++) {
      statements.push(sql`INSERT INTO tag (name) VALUES (${`value-${nextTag++}`})`);
    }
    await Promise.all(statements);
  });
});

(This uses the postgres.js syntax, which fwiw I'm not actually a huge fan of/tied to, but it does technically allow submitted multiple statements like this pretty easy.)

Describe alternatives you've considered

No alternatives, other than just not using pipelining.

Additional context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions