[PR #1937] [CLOSED] feat(server): improve get albums performance #9293

Closed
opened 2026-02-05 14:02:06 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/immich-app/immich/pull/1937
Author: @michelheusschen
Created: 3/4/2023
Status: Closed

Base: mainHead: feat/server-perf-get-albums


📝 Commits (1)

  • 332cc76 feat(server): improve get albums perf and e2e test

📊 Changes

9 files changed (+198 additions, -105 deletions)

View changed files

📝 server/apps/immich/src/api-v1/album/album-repository.ts (+85 -43)
📝 server/apps/immich/src/api-v1/album/album.module.ts (+2 -2)
📝 server/apps/immich/src/api-v1/album/album.service.spec.ts (+12 -9)
📝 server/apps/immich/src/api-v1/album/album.service.ts (+2 -18)
📝 server/apps/immich/src/api-v1/album/dto/get-albums.dto.ts (+3 -1)
📝 server/apps/immich/test/album.e2e-spec.ts (+87 -31)
📝 server/libs/domain/src/share/share.core.ts (+1 -1)
📝 server/libs/domain/test/fixtures.ts (+3 -0)
📝 server/libs/infra/src/db/entities/shared-link.entity.ts (+3 -0)

📄 Description

Improved performance for /api/album endpoint by optimizing the used query and no longer selecting all assets of all albums. Removed AlbumRepository.getListByAssetId(ownerId, assetId) because it has become redundant. Also extended the E2E tests to include shared links and tests for the different query params that the endpoint uses.

Below are some query times from benchmarks ran directly against the DB. I only measured the API time for the 100.000 assets one and before it took 2132ms on average, now the API responds in 40ms.

Asset count Old query New query
5 x 5000 = 25.000 127ms 4.9ms
10 x 5000 = 50.000 501ms 7.8ms
20 x 5000 = 100.000 994ms 14.9ms

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/immich-app/immich/pull/1937 **Author:** [@michelheusschen](https://github.com/michelheusschen) **Created:** 3/4/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/server-perf-get-albums` --- ### 📝 Commits (1) - [`332cc76`](https://github.com/immich-app/immich/commit/332cc768bc2fd5b660b446fcf5f228e0c0ff4d15) feat(server): improve get albums perf and e2e test ### 📊 Changes **9 files changed** (+198 additions, -105 deletions) <details> <summary>View changed files</summary> 📝 `server/apps/immich/src/api-v1/album/album-repository.ts` (+85 -43) 📝 `server/apps/immich/src/api-v1/album/album.module.ts` (+2 -2) 📝 `server/apps/immich/src/api-v1/album/album.service.spec.ts` (+12 -9) 📝 `server/apps/immich/src/api-v1/album/album.service.ts` (+2 -18) 📝 `server/apps/immich/src/api-v1/album/dto/get-albums.dto.ts` (+3 -1) 📝 `server/apps/immich/test/album.e2e-spec.ts` (+87 -31) 📝 `server/libs/domain/src/share/share.core.ts` (+1 -1) 📝 `server/libs/domain/test/fixtures.ts` (+3 -0) 📝 `server/libs/infra/src/db/entities/shared-link.entity.ts` (+3 -0) </details> ### 📄 Description Improved performance for `/api/album` endpoint by optimizing the used query and no longer selecting all assets of all albums. Removed `AlbumRepository.getListByAssetId(ownerId, assetId)` because it has become redundant. Also extended the E2E tests to include shared links and tests for the different query params that the endpoint uses. Below are some query times from benchmarks ran directly against the DB. I only measured the API time for the 100.000 assets one and before it took 2132ms on average, now the API responds in 40ms. | Asset count | Old query | New query | | ------------- | ------------- |------------- | | 5 x 5000 = 25.000 | 127ms | 4.9ms | | 10 x 5000 = 50.000 | 501ms | 7.8ms | | 20 x 5000 = 100.000 | 994ms | 14.9ms | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 14:02:06 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#9293