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
{{ message }}
Repository navigation
Docs: document how to proper make batch inserts/updates #1388
and probably an additional question : when to use pg-copy ?
Reacted by matt212, Qasim Soomro, Marco Galassi, Brian C, Julian Mazzitelli, Joel Mukuthu, Thomas Ruoff, Mike Bostock, Tim Whitbeck, jmargaglione and 40 more
JDBC batch API. That is PreparedStatement#addBatch() enables driver to send multiple "query executions" in a single network roundtrip. Current implementation, however would still split large batches into smaller ones to avoid TCP deadlock.
The actions would be much better:
execute query
...
execute query
execute query
execute query
sync <-- wait for the response from the DB
It seems that using Promise.all() might be the equivalent in node-pg. However:
Does node-pg client state get corrupted if a client.query() call occurs before another client.query() call has resolved, on the same Client?
Does the second client.query() wait until the first client.query() has received a response from the server, or only until the first client.query() has finished sending the query to the server?
[Especially if we don't wrap time-overlapping client.query() calls in a transaction], does node-pg queue server responses appropriately to resolve the correct Promise with the correct response?
Is there any performance advantage to wrapping the calls in a transaction?
I am planning to migrate a PostgreSQL JDBC microservice that uses 1000-batched inserts to achieve desired performance to node-pg, which is why I am trying to figure this out.
@ariofrio Batched queries – pipelining – is broader than batch insert. pg doesn’t have pipelining yet. I think @brianc is working on it.
I am planning to migrate a PostgreSQL JDBC microservice that uses 1000-batched inserts to achieve desired performance to node-pg, which is why I am trying to figure this out.
You should probably try to do it in fewer queries anyway, like #957 (comment).
Activity
qas commentedon Aug 2, 2017
👍
feat(query): support batch inserts
ariofrio commentedon May 8, 2020
Any guidance on this? I'm thinking of this in comparison with the way JDBC's PostgreSQL driver works:
It seems that using Promise.all() might be the equivalent in node-pg. However:
I am planning to migrate a PostgreSQL JDBC microservice that uses 1000-batched inserts to achieve desired performance to node-pg, which is why I am trying to figure this out.
charmander commentedon May 8, 2020
@ariofrio Batched queries – pipelining – is broader than batch insert. pg doesn’t have pipelining yet. I think @brianc is working on it.
You should probably try to do it in fewer queries anyway, like #957 (comment).
sebastianrothbucher commentedon Feb 20, 2022
case it still helps: temp tables can achieve it - see this comment: #956 (comment)