feat: add db.batch() for type-safe batched query execution #1619
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, thanks for the great project!
In this PR I've built a prototype for batch execution of queries as discussed in #904
The benefit of batching/pipelining as described in the Postgres manual:
This PR focuses on setting up the infrastructure to enable adapters to implement batching. Currently it does not actually implement batching for any driver. The main reason for this is that
node-postgresdoes not actually support pipelining curently. (See brianc/node-postgres#3357).Before this lands we need to remove batch support from the Postgres dialect in this codebase. I've added it now to aid testing. Postgres.js does actually support pipelining already, so after a version of this PR lands, we can add support there.
The API I've implemented looks like this:
In this example persons and pets are fully typed.
Main questions: Does this API look alright? Is everything implemented in the right places?
I would then need some guidance on actually implementing batching for the Postgres-js driver (in the other repo). In Postgres-js pipelining works as follows (see here):
How would we actually use this in the adapter?