Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb4a89e
feat: pipeline
cesco69 Feb 4, 2026
e45a691
fix: lint
cesco69 Feb 4, 2026
fb2afe1
fix: lint
cesco69 Feb 4, 2026
7342c9a
docs: pipeline
cesco69 Feb 4, 2026
0554631
fix(pipeline): remove client-side multi-statement validation
Feb 5, 2026
5ea153e
fix(client): move readyForQuery flag outside pipeline mode condition
Feb 5, 2026
adcc093
fix(client): simplified the shift
Feb 5, 2026
34499ce
fix: lint
Feb 5, 2026
c42122a
fix(client): remove wrong check
Feb 5, 2026
7904fea
fix(client): handle unexpected copyInResponse in non-query state
Feb 5, 2026
1c6ab8c
perf(client): batch pipeline queries with single cork/uncork
Feb 5, 2026
681f67d
fix(connection-parameters): restrict pipelineMode to config only
Feb 5, 2026
d893b4e
test(pipeline-mode): add error isolation behavior tests
Feb 5, 2026
7f398b7
fix(client): clean up in-flight parsed statements to prevent memory leak
Feb 5, 2026
3d3b350
test(pipeline-mode): add test
Feb 5, 2026
884aad1
test(pipeline-mode): remove code review comments
Feb 5, 2026
1424fb7
test(pipeline-mode): add more test
Feb 5, 2026
6e2f146
fix(client): reject COPY operations in pipeline mode
Feb 5, 2026
1780d1f
fix(client): improve pipeline mode query completion tracking
Feb 5, 2026
2adc857
refactor(client): extract message target logic and reject custom subm…
Feb 5, 2026
a91f5a6
test(pipeline-mode): add stress and edge case tests (like SAVEPOINT)
Feb 5, 2026
6c8edc0
fix: lint
Feb 5, 2026
587625c
test(pipeline-mode): add data type and concurrency
Feb 5, 2026
b189ed5
perf(bench): add pipeline mode benchmarks
Feb 5, 2026
437179f
test(pipeline-mode): add pool transaction isolation test
Feb 5, 2026
ad32396
docs(queries): update pipeline mode restrictions and add transaction …
Feb 5, 2026
1aacec9
feat(pipeline-mode): add backpressure support with configurable query…
Feb 5, 2026
6e416d8
fix: test
Feb 5, 2026
12f6a2c
test(client): add prepared statement race condition tests for pipelin…
Feb 5, 2026
2c4ac55
feat(pipeline-mode): add query cancellation support with cancel() method
Feb 5, 2026
54b9fc2
fix(pipeline-mode): cancel() preservation through promise chains
Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions docs/pages/features/queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,72 @@ const query = {
},
}
```

## Pipeline Mode

Pipeline mode allows you to send multiple queries to the PostgreSQL server without waiting for the results of previous queries. This can significantly reduce network latency, especially for batch operations or high-latency connections.

### Enabling Pipeline Mode

Pipeline mode is opt-in and can be enabled when creating a client or pool:

```js
// With Client
const client = new Client({ pipelineMode: true })
await client.connect()

// With Pool - all clients will have pipeline mode enabled
const pool = new Pool({ pipelineMode: true })
```

When pipeline mode is enabled, you can submit multiple queries and they will be sent to the server immediately:

```js
// All three queries are sent immediately to the server
const [result1, result2, result3] = await Promise.all([
client.query('SELECT 1 as num'),
client.query('SELECT 2 as num'),
client.query('SELECT 3 as num'),
])
```

### Error Isolation

If one query fails in pipeline mode, other queries continue to execute:

```js
const results = await Promise.allSettled([
client.query('SELECT 1 as num'),
client.query('SELECT * FROM nonexistent_table'), // This will fail
client.query('SELECT 3 as num'),
])

console.log(results[0].status) // 'fulfilled'
console.log(results[1].status) // 'rejected'
console.log(results[2].status) // 'fulfilled' - still succeeds!
```

### Prepared Statements in Pipeline Mode

Prepared statements work in pipeline mode, including concurrent queries with the same statement name:

```js
const results = await Promise.all([
client.query({ name: 'get-user', text: 'SELECT $1::int as id', values: [1] }),
client.query({ name: 'get-user', text: 'SELECT $1::int as id', values: [2] }),
client.query({ name: 'get-user', text: 'SELECT $1::int as id', values: [3] }),
])
```

### Pipeline Mode Restrictions

- **No multi-statement queries**: Queries with multiple SQL statements separated by `;` are rejected
- **No COPY operations**: COPY commands are not supported in pipeline mode
- **JavaScript client only**: Pipeline mode is not available in `pg-native`

### When to Use Pipeline Mode

Pipeline mode is most beneficial when:
- You have many independent queries to execute
- Network latency is high (cloud databases, cross-region connections)
- You're doing batch operations
Loading