-
Notifications
You must be signed in to change notification settings - Fork 3k
perf: added inline relationships (use JOINs instead of SELECTs) #14152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
if ((isFieldLocalized || parentIsLocalized) && _locales) { | ||
_locales.columns = _locales.columns || ({} as Result['columns']) | ||
_locales.columns[fieldPath] = true | ||
} else if (adapter.tables[currentTableName]?.[fieldPath]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use localization in my setup yet, so I'm not sure how correct this is.
I wrote it based on samples from other places in the file
if ((isFieldLocalized || parentIsLocalized) && _locales) { | ||
_locales.with = _locales.with || {} | ||
_locales.with[fieldPath] = true | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use localization in my setup yet, so I'm not sure how correct this is.
I wrote it based on samples from other places in the file
: { id: false, _parentID: false }, | ||
with: {}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use localization in my setup yet, so I'm not sure how correct this is.
I wrote it based on samples from other places in the file
Object.keys(withRelationship.with._locales.columns).length === 1 | ||
) { | ||
delete withRelationship.with._locales | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't use localization in my setup yet, so I'm not sure how correct this is.
I wrote it based on samples from other places in the file
What?
Adds the ability to inline relationships (i.e. use JOINs instead of separate SELECTs when fetching from the database).
This is controlled by a new
inline
flag that can be enabled when defining a relationship/upload field.This feature works particularly well when used alongside the
select
parameter.Why?
To reduce the total number of database queries that are generated when fetching, saving or updating collections. This is particularly impactful on collections with multiple relationship/upload fields. I've seen it reduce from 15-30 queries to the database in a single operation to just 5-10.
How?
By configuring Drizzle to join with the related collection, via the
with
parameter.