Skip to content

Commit 9948040

Browse files
authored
perf(ui): only select necessary data for relationship options (#12251)
### What? Improve performance of the relationship select options by reducing the fetched documents to only necessary data. ### Why? The relationship select only requires an ID and title. Fetching the whole document instead leads to slow performance on collections with large documents. ### How? Add a select parameter to the query, the same way it is done in the [WhereBuilder](https://github.com/payloadcms/payload/blob/main/packages/ui/src/elements/WhereBuilder/Condition/Relationship/index.tsx#L105-L107) already.
1 parent b7ae4ee commit 9948040

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/ui/src/fields/Relationship/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ const RelationshipFieldComponent: RelationshipFieldClientComponent = (props) =>
271271
limit: maxResultsPerRequest,
272272
locale,
273273
page: lastLoadedPageToUse,
274+
select: {
275+
[fieldToSearch]: true,
276+
},
274277
sort: fieldToSort,
275278
where: {
276279
and: [

0 commit comments

Comments
 (0)