You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
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.
Reacted by Sheldon Dsouza, Louis Raymond, David Orchard, Matthew DeGuzman, Tim C, Dan McGee, Tobias Burger, Josh Giles and Sean
Activity
Jille commentedon Dec 21, 2021
#1352 could at least alleviate the inserting part of this, but CopyFrom can't do everything regular inserts can do.
danielbprice commentedon Jan 6, 2022
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 commentedon Sep 23, 2024
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.
jgiles commentedon Mar 30, 2026
See #4342 for batching different kinds of queries