I want to insert lots of records in batches. Some of the fields are varchars, so I want to pass that data as dynamic parameters. I am aware I could use exec_batch()
, but that wouldn't be a good solution performance-wise, as it seems to send each row to the DB in separate calls. So what I basically want is to insert records in batches via building larger INSERT INTO
statements that would insert (say) 1000 records each. But that would mean thousands of dynamic parameters for each of those inserts.
Methods like exec_drop()
can accept tuples, but up to 12 elements. So how can I pass thousands of values of different/mixed types (ints, strings, etc.)? I am guessing I should use a vector of the so called "trait objects" somehow?
Perhaps the answer is in the docs, but I am still new to Rust and can't quite understand how to achieve that.