Using Rayon with SQLX "iterator-like" stream of rows

245 Views Asked by At

Rust SQLX lib provides an iterator-like interface fetch(...) usually used with while let Some(row) = rows.try_next().await? {...} construct. In my case, each row may take some time to process, so I would like to use Rayon's par_iter(), but that requires a real iterator. Using fetch_all is not an option because all rows may simply not fit into memory.

How can I use Rayon's par_iter to process millions of rows produced by the sqlx's fetch stream?

0

There are 0 best solutions below