Skip to content
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

perf(server): optimize getByIds query #7918

Merged
merged 9 commits into from Mar 14, 2024
Merged

perf(server): optimize getByIds query #7918

merged 9 commits into from Mar 14, 2024

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Mar 13, 2024

Description

This PR splits getByIds into two methods: one that doesn't include any relations by default and one that includes all of them. Of its current usages, all of the ones internal to the server have been checked to see which, if any, relations are required (most of them don't require any). The ones used for API responses use the variant with all relations since they're more work to figure out.

Also, as suggested in #7909, this adds a few indices needed for queries involving the stack, tag and person relations to be performant. I tested and can confirm the massive performance difference described in that issue.

Fixes #7909

Copy link

cloudflare-pages bot commented Mar 13, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: ae024fe
Status: ✅  Deploy successful!
Preview URL: https://1331f971.immich.pages.dev
Branch Preview URL: https://perf-server-getbyids.immich.pages.dev

View logs

remove index from person entity

add to face entity

fix
server/src/domain/download/download.service.ts Outdated Show resolved Hide resolved
server/src/infra/entities/asset-stack.entity.ts Outdated Show resolved Hide resolved
@mertalev mertalev merged commit ee8e8a0 into main Mar 14, 2024
24 checks passed
@mertalev mertalev deleted the perf/server-getbyids branch March 14, 2024 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sub-optimal SQL query found / index suggestions
2 participants