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

# fetchIdentifiers(_:batchSize:)

Returns a collection of persistent identifiers, in batches, where each identifier represents a single model that satisfies the criteria of the specified fetch descriptor.

## Declaration

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

## Parameters

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

## Return Value

Return Value The collection of persistent identifiers. If no models match the descriptor’s criteria, the array is empty.

## Discussion

Discussion The collection automatically fetches subsequent batches as you iterate over the identifiers, or access one at a specific index.

## See Also

### Fetching only persistent identifiers

- [fetchIdentifiers(_:)](swiftdata/modelcontext/fetchidentifiers(_:).md)
