immich icon indicating copy to clipboard operation
immich copied to clipboard

Slow /api/albums endpoint

Open C-Otto opened this issue 1 year ago • 7 comments

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

  • [X] Server
  • [X] Web
  • [ ] Mobile

C-Otto avatar Sep 11 '24 12:09 C-Otto

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

mmomjian avatar Sep 11 '24 12:09 mmomjian

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.

C-Otto avatar Sep 11 '24 12:09 C-Otto

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.

mmomjian avatar Sep 11 '24 13:09 mmomjian

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.

mertalev avatar Sep 11 '24 15:09 mertalev

Should we close #11071 in favor of this one?

danieldietzler avatar Sep 21 '24 18:09 danieldietzler

No, these are different issues, see my comment above

C-Otto avatar Sep 21 '24 19:09 C-Otto

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)

SamueleLorefice avatar Sep 23 '24 17:09 SamueleLorefice

The album queries have been reworked recently and #11071 has been resolved with them. Closing this as it should've seen the same performance issues.

danieldietzler avatar Apr 01 '25 19:04 danieldietzler