Closed yatesco closed 1 year ago
If you just have a QueryStream
, your item can either be a set of columns, or it can be a row. When calling the into_row_stream
, it skips the column infos and just returns rows. Neither of these streams load anything to the memory, you have to poll the stream to get data out. It takes X amount of bytes from the wire at a time, and fetches more when polling and the cache is completely empty.
Use into_row_stream
if you just executed one query and the row data is uniform. If you have multiple queries, you have to match the item and react accordingly if you get a new column info, because the following rows are having differently shaped data.
And the streams must always be iterated completely before querying again. We flush the streams to the end in the next query, and trigger a warning to the logs.
Thanks - that's exactly what I was looking for.
Hi there - thanks for this!
When I use https://docs.rs/tiberius/latest/tiberius/struct.QueryStream.html#method.into_row_stream, does it use a cursor/fetch items in batches/fetch all results in a single query? I assume it uses a cursor, but I want to check.
When I start my app it bootstraps by replaying all events from the DB. This could be 100Ks, and I definitely don't want to load them all in one go, so I'm just checking my assumptions.
I tried to follow the code but got lost in futures somewhere :-).
Thanks!