<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "swift: 5.9.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftData",
  "identifier" : "/documentation/SwiftData/FetchDescriptor/relationshipKeyPathsForPrefetching",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData15FetchDescriptorV34relationshipKeyPathsForPrefetchingSays07PartialF4PathCyxGGvp"
  },
  "title" : "relationshipKeyPathsForPrefetching"
}
-->

# relationshipKeyPathsForPrefetching

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

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

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)