Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for pgx batching #1275

Closed
johanbrandhorst opened this issue Nov 8, 2021 · 3 comments · Fixed by #1437
Closed

Feature request: Support for pgx batching #1275

johanbrandhorst opened this issue Nov 8, 2021 · 3 comments · Fixed by #1437

Comments

@johanbrandhorst
Copy link
Contributor

As mentioned in #472, pgx batching can be a very important tool for efficient inserts and queries. There doesn't seem to be any way to use the generated methods with the existing pgx batching interface. The pgx batching interface is defined by the Batch type and its Queue method. It would be neat if we could have something similar to the generated New(db DBTX) *Queries function that operates on a pgx.Batch.

We'd need to think a little about the design, since in an ideal world we'd still be able to get typed responses for each entry on the batch. Maybe each function on the type that operates on a batch should take a callback or something for how to process the returned data?

@Jille
Copy link
Contributor

Jille commented Dec 21, 2021

#1352 could at least alleviate the inserting part of this, but CopyFrom can't do everything regular inserts can do.

@danielbprice
Copy link
Contributor

For what it's worth, I recently migrated some code from "one insert at a time" to "1000 inserts in a batch" and got at least 100x speedup (it's now so fast I don't care). As a result, I more-or-less can't use sqlc in my project, even though I'd like to.

@fedorkanin
Copy link

As far as I understand, currently there is still no support for batching different kinds of queries, is there? This would be really handy, as it's going to reduce the number of roundtrips for complex queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants