---
title: "fetch(_:batchSize:)"
framework: swiftdata
role: symbol
role_heading: Instance Method
path: "swiftdata/modelcontext/fetch(_:batchsize:)"
---

# fetch(_:batchSize:)

Returns a collection of typed models, in batches, which match the criteria of the specified fetch descriptor.

## Declaration

```swift
func fetch<T>(_ descriptor: FetchDescriptor<T>, batchSize: Int) throws -> FetchResultsCollection<T> where T : PersistentModel
```

## Parameters

- `descriptor`: A fetch descriptor that provides the configuration for the fetch.
- `batchSize`: The maximum number of models to include in each batch.

## Return Value

Return Value The collection of typed models that satisfy the criteria of the fetch descriptor. If no models match the criteria, the collection is empty.

## Discussion

Discussion As you access the models in the returned collection (either sequentially, or directly using subscripting), the context automatically fetches the necessary batches.

## See Also

### Fetching models

- [fetch(_:)](swiftdata/modelcontext/fetch(_:).md)
- [fetchCount(_:)](swiftdata/modelcontext/fetchcount(_:).md)
- [FetchDescriptor](swiftdata/fetchdescriptor.md)
- [FetchResultsCollection](swiftdata/fetchresultscollection.md)
- [enumerate(_:batchSize:allowEscapingMutations:block:)](swiftdata/modelcontext/enumerate(_:batchsize:allowescapingmutations:block:).md)
- [model(for:)](swiftdata/modelcontext/model(for:).md)
- [registeredModel(for:)](swiftdata/modelcontext/registeredmodel(for:).md)
