fetchBatchedResults

fun fetchBatchedResults(batchSize: Int = 1000, sortOrder: SortOrder = SortOrder.ASC): Flow<Flow<ResultRow>>

Iterates over multiple executions of this SELECT query with its LIMIT clause set to batchSize until the amount of results retrieved from the database is less than batchSize.

This query's FieldSet will be ordered by the first auto-increment column.

Note: There is a possibility that the final batched sub-collection emitted may be empty, as the flow of results cannot be pre-checked before being yielded. Whether the amount of results retrieved is less than the provided batch size will not be determined until the batch is consumed on the user-end, which means the amount of results in a batch may be zero.

Return

Retrieved results as a collection of batched ResultRow sub-collections.

Parameters

batchSize

Size of each sub-collection to return.

sortOrder

Order in which the results should be retrieved.

Samples

org.jetbrains.exposed.v1.r2dbc.sql.tests.shared.dml.FetchBatchedResultsTests.testFetchBatchedResultsWithWhereAndSetBatchSize