Files
immich/server
bo0tzz bb024c8626 perf(server): check shared link asset access without scanning the album (#32411)
* perf(server): check shared link asset access without scanning the album

checkSharedLinkAccess runs on every thumbnail, preview, playback and asset
info request made through a shared link. It joined every asset of the
link's album and only then filtered on an array overlap across four
outer-joined columns, so each request cost O(album size).

Split it into two branches (link assets, album assets) that find the
requested ids through the asset pkey / livePhotoVideoId index and then
probe the album_asset pkey.

Median per request, PG 14, 1.36M-asset instance:

| album behind the link | before | after   |
|-----------------------|--------|---------|
| 290 assets            | 2.1 ms | 0.17 ms |
| 150k assets           | 296 ms | 0.19 ms |

* chore: clean up

---------

Co-authored-by: Jason Rasmussen <jason@rasm.me>
2026-10-13 18:33:29 -04:00
..
…
…