immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
45.75k stars 2.22k forks source link

Slow /api/albums endpoint #12570

Open C-Otto opened 2 weeks ago

C-Otto commented 2 weeks ago

The bug

When the /api/albums endpoint is queried, for example when going to the albums page or trying to add assets to an album, this takes a lot of time. I'd like the response to be quicker, possibly with some details loaded in separate requests.

In my case, with a server I consider fast, with lots of dedicated RAM and fast SSDs for the database, the endpoint takes 903ms to load. I currently have 225 albums.

Related to #11071

The OS that Immich Server is running on

Debian Stable

Version of Immich Server

v1.114.0

Platform with the issue

mmomjian commented 2 weeks ago

Seems to be a duplicate of #11071 as you mentioned, what makes this a new issue?

C-Otto commented 2 weeks ago

It's not the browser that struggles, but the server. The issue is unrelated to the loading of thumbnails, as the endpoint only returns URLs. Switching to/from the list mode on the albums page is almost instant in my browser.

mmomjian commented 2 weeks ago

How many albums do you have? Edit: I see 225. 900ms doesn’t seem crazy unreasonable enough to be a bug to me, but I’ll give it a bit for someone else to chime in.

mertalev commented 2 weeks ago

I'd imagine that fetching albums for the albums page should be at least an order of magnitude faster than that, possibly closer to two. There are a lot of queries that are just slow and unoptimized. While porting things over to the Kysely query builder, I've also been doing an optimization pass on these.

danieldietzler commented 5 days ago

Should we close #11071 in favor of this one?

C-Otto commented 5 days ago

No, these are different issues, see my comment above

SamueleLorefice commented 3 days ago

Just going to add... on loading the albums page on my end, the albums endpoint request takes 5.1s on the server to load. This is with around 6k albums. Creating albums takes around 1.5s/1.7s (Via direct API calls)