---
title: relationshipKeyPathsForPrefetching
framework: swiftdata
role: symbol
role_heading: Instance Property
path: swiftdata/fetchdescriptor/relationshipkeypathsforprefetching
---

# relationshipKeyPathsForPrefetching

The key paths that identify any related models to include as part of the fetch.

## Declaration

```swift
var relationshipKeyPathsForPrefetching: [PartialKeyPath<T>]
```

## Discussion

Discussion Prefetching enables SwiftData to obtain any related models in a single fetch, instead of incurring subsequent access to the persistent storage as you access each related model. For example, given an Employee model with a relationship to a Department model, and suppose you fetch all employees as you want to display both their name and the name of the department where they work. In such a scenario, the model context may need to perform additional fetches for each individual department, resulting in significant overhead. You can avoid this by prefetching the department relationship as part of the employee fetch. The default value is an empty array.

## See Also

### Specifying the fetched attributes

- [propertiesToFetch](swiftdata/fetchdescriptor/propertiestofetch.md)
