Best lib for fast PostgreSQL JSON Inserts

I need to write a utility to fetch large amounts of data (HTTP) then insert it into a Postgres DB, as JSON objects. IOW the data is unstructured and there will only be a single table, with the usual id/json fields.

There will be hundreds of millions of rows. Pretty much the sole criteria here for picking a library is the speed of bulk JSON insert. Based on that, any opinions of whether I should go with Diesel vs. sqlx vs. rust-postgres?

(This has to be done in a day or two so not a lot of time for experimentation.)

Going with diesel. It has possibly the best performance and makes bulk inserts really easy: copy_from in diesel - Rust

FYI, using postgres-rust I am able to get ~one million writes to a ten-field table using the COPY method (BinaryCopyInWriter) in around a half-second on my M1 Mac (local Postgres instance).

That'll do.

1 Like