sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.49k stars 443 forks source link

Preferred batching implementation #1006

Closed aniketfuryrocks closed 1 year ago

aniketfuryrocks commented 1 year ago

Hi, @sfackler. First of all thanks for the amazing crate. We are working with high frequency data that we want to write to postgres in the most efficient manner possible. First thing that came into mind is to batch insert using prepared statements. But that's limited to a single number. Is there a more flexible implementation using which we can insert many rows in the most efficient way possible. Thanks https://github.com/blockworks-foundation/lite-rpc/pull/92

Current implementation that I think makes matter better, but know can be optimized further https://github.com/blockworks-foundation/lite-rpc/blob/f98c8f2e4cd01fad321a0c9ea86b004021c18e53/src/workers/postgres.rs

sfackler commented 1 year ago

A COPY query is generally the most efficient method to perform bulk inserts.