# fetchBatchedResults

fun fetchBatchedResults(batchSize: Int = 1000, sortOrder: SortOrder = SortOrder.ASC): Iterable<Iterable<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.

#### 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.sql.tests.shared.dml.FetchBatchedResultsTests.testFetchBatchedResultsWithWhereAndSetBatchSize