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

feat(server): optimize get asset query #7176

Merged
merged 15 commits into from Feb 18, 2024

Conversation

mertalev
Copy link
Contributor

@mertalev mertalev commented Feb 18, 2024

Description

This PR fixes #7166 by simplifying the legacy query used in getAllAssets:

  • Removes unnecessary joins
  • Fetches data in one query vs two
    • TypeORM split the old query into two: a query to fetch the IDs and a second query to fetch the assets
  • Removes DISTINCT clause due to use of limit/offset rather than skip/take
  • Adds index on fileCreatedAt for faster sorting
  • Adds updated method to asset repository, removing the legacy code

Copy link

cloudflare-pages bot commented Feb 18, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: cb67b3f
Status: ✅  Deploy successful!
Preview URL: https://0dcb070f.immich.pages.dev
Branch Preview URL: https://feat-server-optimize-get-ass.immich.pages.dev

View logs

Copy link
Contributor

@fyfrey fyfrey left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@danieldietzler danieldietzler left a comment

Choose a reason for hiding this comment

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

LGTM

@alextran1502 alextran1502 merged commit 857ec04 into main Feb 18, 2024
25 checks passed
@alextran1502 alextran1502 deleted the feat/server-optimize-get-asset-query branch February 18, 2024 18:22
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.

800,000+ Assets, Performance is unusable
4 participants