Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

avoid n+1 query on file_metadata delete #6747

Merged
merged 1 commit into from
Mar 26, 2024
Merged

avoid n+1 query on file_metadata delete #6747

merged 1 commit into from
Mar 26, 2024

Conversation

no-reply
Copy link
Contributor

Hyrax should avoid looping over ids when it could use a custom query. e.g. we should never be doing my_resource.member_ids.each and looking up members instead doing query_service.find_members(resource: my_resource). doing this creates two problems:

  • it prevents adapters from optimizing n+1 query problems for large sets of ids.
  • it locks hyrax into modelling details (relationship directionality) that applications may want to avoid.

there are probably other places this problem exists, but i'm aware of this one and wanted to get a patch in right away.

@samvera/hyrax-code-reviewers

Hyrax should avoid looping over ids when it could use a custom query. e.g. we
should never be doing `my_resource.member_ids.each` and looking up members instead doing
`query_service.find_members(resource: my_resource)`. doing this creates two
problems:

  - it prevents adapters from optimizing n+1 query problems for large sets of
  ids.
  - it locks hyrax into modelling details (relationship directionality) that
  applications may want to avoid.

there are probably other places this problem exists, but i'm aware of this one
and wanted to get a patch in right away.

note that this proposes unceremoniously removing the `property:` step
argument. if we need to keep this, we could choose to make in `nil` by default
and fall back to the old code if a value is provided. i can't see any reason a
caller would want to change the property of this step though, and i strongly
doubt anyone downstream is doing so.
Copy link
Contributor

@dlpierce dlpierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! No reason to have n+1 situations. Thanks for offering to track down any others we've created.

@no-reply no-reply merged commit 56c25f0 into main Mar 26, 2024
6 checks passed
@no-reply no-reply deleted the find_files branch March 26, 2024 19:41
@dlpierce dlpierce added the notes-minor Release Notes: Non-breaking features label Mar 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
notes-minor Release Notes: Non-breaking features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants