mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(server): improve checkAlbumAccess query performance (#22467)
* Fix slow SQL query in checkAlbumAccess caused by the array overlap operator && * Update access.repository.sql * Rewrite the query to pass assetIds once as a single array parameter
This commit is contained in:
parent
1a2a46014e
commit
9da138e01e
2 changed files with 17 additions and 5 deletions
|
|
@ -71,6 +71,11 @@ where
|
|||
and "shared_link"."albumId" in ($2)
|
||||
|
||||
-- AccessRepository.asset.checkAlbumAccess
|
||||
with
|
||||
"target" as (
|
||||
select
|
||||
array[$1]::uuid[] as "ids"
|
||||
)
|
||||
select
|
||||
"asset"."id",
|
||||
"asset"."livePhotoVideoId"
|
||||
|
|
@ -82,8 +87,12 @@ from
|
|||
left join "album_user" as "albumUsers" on "albumUsers"."albumsId" = "album"."id"
|
||||
left join "user" on "user"."id" = "albumUsers"."usersId"
|
||||
and "user"."deletedAt" is null
|
||||
cross join "target"
|
||||
where
|
||||
array["asset"."id", "asset"."livePhotoVideoId"] && array[$1]::uuid[]
|
||||
(
|
||||
"asset"."id" = any (target.ids)
|
||||
or "asset"."livePhotoVideoId" = any (target.ids)
|
||||
)
|
||||
and (
|
||||
"album"."ownerId" = $2
|
||||
or "user"."id" = $3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue