2025-08-23 05:18:03.122 UTC [1] LOG: starting PostgreSQL 14.18 (Debian 14.18-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2025-08-23 05:18:03.123 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2025-08-23 05:18:03.123 UTC [1] LOG: listening on IPv6 address "::", port 5432 2025-08-23 05:18:03.132 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2025-08-23 05:18:03.145 UTC [32] LOG: database system was shut down at 2025-08-23 05:18:01 UTC 2025-08-23 05:18:03.172 UTC [1] LOG: database system is ready to accept connections 2025-08-23 05:18:08.367 UTC [55] LOG: duration: 20.218 ms statement: SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database 2025-08-23 05:19:09.344 UTC [59] LOG: duration: 8335.498 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:19:09.345 UTC [59] LOG: duration: 8419.818 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:19:09.345 UTC [59] DETAIL: parameters: $1 = '1' 2025-08-23 05:19:09.411 UTC [60] LOG: duration: 26.846 ms execute : select "album_asset"."albumsId" as "albumId", min(("asset"."localDateTime" AT TIME ZONE 'UTC'::text)::date) as "startDate", max(("asset"."localDateTime" AT TIME ZONE 'UTC'::text)::date) as "endDate", max("asset"."updatedAt") as "lastModifiedAssetTimestamp", count("asset"."id")::int as "assetCount" from "asset" inner join "album_asset" on "album_asset"."assetsId" = "asset"."id" where "asset"."visibility" in ('archive', 'timeline') and "album_asset"."albumsId" in ($1) and "asset"."deletedAt" is null group by "album_asset"."albumsId" 2025-08-23 05:19:09.411 UTC [60] DETAIL: parameters: $1 = '365ac62f-8b02-488f-aa6a-11fbaaecfe13' 2025-08-23 05:19:09.651 UTC [58] LOG: duration: 101.689 ms execute : with "cte" as (select "asset"."duration", "asset"."id", "asset"."visibility", "asset"."isFavorite", asset.type = 'IMAGE' as "isImage", asset."deletedAt" is not null as "isTrashed", "asset"."livePhotoVideoId", extract(epoch from (asset."localDateTime" - asset."fileCreatedAt" at time zone 'UTC'))::real / 3600 as "localOffsetHours", "asset"."ownerId", "asset"."status", asset."fileCreatedAt" at time zone 'utc' as "fileCreatedAt", encode("asset"."thumbhash", 'base64') as "thumbhash", "asset_exif"."city", "asset_exif"."country", "asset_exif"."projectionType", coalesce(case when asset_exif."exifImageHeight" = 0 or asset_exif."exifImageWidth" = 0 then 1 when "asset_exif"."orientation" in ('5', '6', '7', '8', '-90', '90') then round(asset_exif."exifImageHeight"::numeric / asset_exif."exifImageWidth"::numeric, 3) else round(asset_exif."exifImageWidth"::numeric / asset_exif."exifImageHeight"::numeric, 3) end, 1) as "ratio" from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" where "asset"."deletedAt" is null and "asset"."visibility" in ('archive', 'timeline') and date_trunc('MONTH', "localDateTime" AT TIME ZONE 'UTC') AT TIME ZONE 'UTC' = $1 and exists (select from "album_asset" where "album_asset"."assetsId" = "asset"."id" and "album_asset"."albumsId" = $2::uuid) order by "asset"."fileCreatedAt" desc), "agg" as (select coalesce(array_agg("city"), '{}') as "city", coalesce(array_agg("country"), '{}') as "country", coalesce(array_agg("duration"), '{}') as "duration", coalesce(array_agg("id"), '{}') as "id", coalesce(array_agg("visibility"), '{}') as "visibility", coalesce(array_agg("isFavorite"), '{}') as "isFavorite", coalesce(array_agg("isImage"), '{}') as "isImage", coalesce(array_agg("isTrashed"), '{}') as "isTrashed", coalesce(array_agg("livePhotoVideoId"), '{}') as "livePhotoVideoId", coalesce(array_agg("fileCreatedAt"), '{}') as "fileCreatedAt", coalesce(array_agg("localOffsetHours"), '{}') as "localOffsetHours", coalesce(array_agg("ownerId"), '{}') as "ownerId", coalesce(array_agg("projectionType"), '{}') as "projectionType", coalesce(array_agg("ratio"), '{}') as "ratio", coalesce(array_agg("status"), '{}') as "status", coalesce(array_agg("thumbhash"), '{}') as "thumbhash" from "cte") select to_json(agg)::text as "assets" from "agg" 2025-08-23 05:19:09.651 UTC [58] DETAIL: parameters: $1 = '2024-09-01 00:00:00+00', $2 = '365ac62f-8b02-488f-aa6a-11fbaaecfe13' 2025-08-23 05:19:09.652 UTC [58] LOG: duration: 101.670 ms plan: Query Text: with "cte" as (select "asset"."duration", "asset"."id", "asset"."visibility", "asset"."isFavorite", asset.type = 'IMAGE' as "isImage", asset."deletedAt" is not null as "isTrashed", "asset"."livePhotoVideoId", extract(epoch from (asset."localDateTime" - asset."fileCreatedAt" at time zone 'UTC'))::real / 3600 as "localOffsetHours", "asset"."ownerId", "asset"."status", asset."fileCreatedAt" at time zone 'utc' as "fileCreatedAt", encode("asset"."thumbhash", 'base64') as "thumbhash", "asset_exif"."city", "asset_exif"."country", "asset_exif"."projectionType", coalesce(case when asset_exif."exifImageHeight" = 0 or asset_exif."exifImageWidth" = 0 then 1 when "asset_exif"."orientation" in ('5', '6', '7', '8', '-90', '90') then round(asset_exif."exifImageHeight"::numeric / asset_exif."exifImageWidth"::numeric, 3) else round(asset_exif."exifImageWidth"::numeric / asset_exif."exifImageHeight"::numeric, 3) end, 1) as "ratio" from "asset" inner join "asset_exif" on "asset"."id" = "asset_exif"."assetId" where "asset"."deletedAt" is null and "asset"."visibility" in ('archive', 'timeline') and date_trunc('MONTH', "localDateTime" AT TIME ZONE 'UTC') AT TIME ZONE 'UTC' = $1 and exists (select from "album_asset" where "album_asset"."assetsId" = "asset"."id" and "album_asset"."albumsId" = $2::uuid) order by "asset"."fileCreatedAt" desc), "agg" as (select coalesce(array_agg("city"), '{}') as "city", coalesce(array_agg("country"), '{}') as "country", coalesce(array_agg("duration"), '{}') as "duration", coalesce(array_agg("id"), '{}') as "id", coalesce(array_agg("visibility"), '{}') as "visibility", coalesce(array_agg("isFavorite"), '{}') as "isFavorite", coalesce(array_agg("isImage"), '{}') as "isImage", coalesce(array_agg("isTrashed"), '{}') as "isTrashed", coalesce(array_agg("livePhotoVideoId"), '{}') as "livePhotoVideoId", coalesce(array_agg("fileCreatedAt"), '{}') as "fileCreatedAt", coalesce(array_agg("localOffsetHours"), '{}') as "localOffsetHours", coalesce(array_agg("ownerId"), '{}') as "ownerId", coalesce(array_agg("projectionType"), '{}') as "projectionType", coalesce(array_agg("ratio"), '{}') as "ratio", coalesce(array_agg("status"), '{}') as "status", coalesce(array_agg("thumbhash"), '{}') as "thumbhash" from "cte") select to_json(agg)::text as "assets" from "agg" Subquery Scan on agg (cost=1225.50..1225.53 rows=1 width=32) -> Aggregate (cost=1225.50..1225.51 rows=1 width=512) -> Sort (cost=1225.35..1225.36 rows=2 width=219) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.68..1225.34 rows=2 width=219) -> Nested Loop (cost=1.12..1220.39 rows=2 width=131) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..13.63 rows=404 width=16) Index Cond: ("albumsId" = '365ac62f-8b02-488f-aa6a-11fbaaecfe13'::uuid) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.99 rows=1 width=115) Index Cond: (id = album_asset."assetsId") Filter: (("deletedAt" IS NULL) AND (visibility = ANY ('{archive,timeline}'::asset_visibility_enum[])) AND ((date_trunc('MONTH'::text, ("localDateTime" AT TIME ZONE 'UTC'::text)) AT TIME ZONE 'UTC'::text) = '2024-09-01 00:00:00+00'::timestamp with time zone)) -> Index Scan using asset_exif_pkey on asset_exif (cost=0.56..2.42 rows=1 width=91) Index Cond: ("assetId" = asset.id) 2025-08-23 05:19:40.194 UTC [60] LOG: duration: 7237.379 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:19:40.194 UTC [60] LOG: duration: 7309.936 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:19:40.194 UTC [60] DETAIL: parameters: $1 = '1' 2025-08-23 05:19:48.215 UTC [59] LOG: duration: 7793.136 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:19:48.215 UTC [59] LOG: duration: 7799.118 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:19:48.215 UTC [59] DETAIL: parameters: $1 = '1' 2025-08-23 05:19:51.787 UTC [58] LOG: duration: 9643.334 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:19:51.787 UTC [61] LOG: duration: 9647.540 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:19:51.787 UTC [58] LOG: duration: 9671.033 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:19:51.787 UTC [58] DETAIL: parameters: $1 = '1' 2025-08-23 05:19:51.787 UTC [61] LOG: duration: 9679.593 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:19:51.787 UTC [61] DETAIL: parameters: $1 = '1' 2025-08-23 05:19:55.664 UTC [60] LOG: duration: 7407.073 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:19:55.664 UTC [60] LOG: duration: 7410.421 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:19:55.664 UTC [60] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:03.768 UTC [59] LOG: duration: 11732.756 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:03.768 UTC [61] LOG: duration: 11806.841 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:03.768 UTC [62] LOG: duration: 11692.114 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:03.768 UTC [59] LOG: duration: 11735.699 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:03.768 UTC [59] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:03.768 UTC [61] LOG: duration: 11809.956 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:03.768 UTC [61] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:03.768 UTC [62] LOG: duration: 11724.020 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:03.768 UTC [62] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:15.208 UTC [61] LOG: duration: 11269.668 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:15.208 UTC [58] LOG: duration: 11260.802 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:15.208 UTC [63] LOG: duration: 11279.075 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:15.208 UTC [61] LOG: duration: 11273.025 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:15.208 UTC [61] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:15.208 UTC [58] LOG: duration: 11263.980 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:15.208 UTC [58] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:15.208 UTC [63] LOG: duration: 11342.977 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:15.208 UTC [63] DETAIL: parameters: $1 = '1' 2025-08-23 05:20:22.293 UTC [63] LOG: duration: 7019.073 ms plan: Query Text: update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) Update on album (cost=0.00..111513666.56 rows=0 width=0) -> Seq Scan on album (cost=0.00..111513666.56 rows=84878 width=22) Filter: ((("albumThumbnailAssetId" IS NULL) AND (SubPlan 2)) OR (("albumThumbnailAssetId" IS NOT NULL) AND (NOT (SubPlan 3)))) SubPlan 1 -> Limit (cost=1293.56..1293.56 rows=1 width=24) -> Sort (cost=1293.56..1294.63 rows=429 width=24) Sort Key: asset."fileCreatedAt" DESC -> Nested Loop (cost=1.12..1291.41 rows=429 width=24) -> Index Only Scan using album_asset_pkey on album_asset (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset (cost=0.56..2.97 rows=1 width=24) Index Cond: (id = album_asset."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 2 -> Nested Loop (cost=1.12..1291.41 rows=429 width=0) -> Index Only Scan using album_asset_pkey on album_asset album_asset_1 (cost=0.56..15.27 rows=429 width=16) Index Cond: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_1 (cost=0.56..2.97 rows=1 width=16) Index Cond: (id = album_asset_1."assetsId") Filter: ("deletedAt" IS NULL) SubPlan 3 -> Nested Loop (cost=1.12..5.97 rows=1 width=0) -> Index Scan using "album_asset_assetsId_idx" on album_asset album_asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: ("assetsId" = album."albumThumbnailAssetId") Filter: ("albumsId" = album.id) -> Index Scan using "asset_id_stackId_idx" on asset asset_2 (cost=0.56..2.98 rows=1 width=16) Index Cond: (id = album."albumThumbnailAssetId") Filter: ("deletedAt" IS NULL) JIT: Functions: 41 Options: Inlining true, Optimization true, Expressions true, Deforming true 2025-08-23 05:20:22.293 UTC [63] LOG: duration: 7022.466 ms execute : update "album" set "albumThumbnailAssetId" = (select "album_asset"."assetsId" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" order by "asset"."fileCreatedAt" desc limit $1) where (("albumThumbnailAssetId" is null and exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id")) or ("albumThumbnailAssetId" is not null and not exists (select 1 as "1" from "album_asset" inner join "asset" on "album_asset"."assetsId" = "asset"."id" and "asset"."deletedAt" is null where "album_asset"."albumsId" = "album"."id" and "album"."albumThumbnailAssetId" = "album_asset"."assetsId"))) 2025-08-23 05:20:22.293 UTC [63] DETAIL: parameters: $1 = '1'