mirror of
https://github.com/immich-app/immich.git
synced 2026-03-01 14:40:09 -05:00
fix: tune up the performance of the getByDayOfYear query. (#26495)
This commit is contained in:
parent
dc4da4b3d6
commit
aa87d1b9a3
@ -123,13 +123,13 @@ with
|
||||
) as "year"
|
||||
)
|
||||
select
|
||||
"a".*,
|
||||
to_json("asset_exif") as "exifInfo"
|
||||
"a".*
|
||||
from
|
||||
"today"
|
||||
inner join lateral (
|
||||
select
|
||||
"asset".*
|
||||
"asset"."id",
|
||||
"asset"."localDateTime"
|
||||
from
|
||||
"asset"
|
||||
inner join "asset_job_status" on "asset"."id" = "asset_job_status"."assetId"
|
||||
@ -151,7 +151,6 @@ with
|
||||
limit
|
||||
$7
|
||||
) as "a" on true
|
||||
inner join "asset_exif" on "a"."id" = "asset_exif"."assetId"
|
||||
)
|
||||
select
|
||||
date_part(
|
||||
|
||||
@ -404,7 +404,7 @@ export class AssetRepository {
|
||||
(qb) =>
|
||||
qb
|
||||
.selectFrom('asset')
|
||||
.selectAll('asset')
|
||||
.select(['asset.id', 'asset.localDateTime'])
|
||||
.innerJoin('asset_job_status', 'asset.id', 'asset_job_status.assetId')
|
||||
.where(sql`(asset."localDateTime" at time zone 'UTC')::date`, '=', sql`today.date`)
|
||||
.where('asset.ownerId', '=', anyUuid(ownerIds))
|
||||
@ -423,9 +423,7 @@ export class AssetRepository {
|
||||
.as('a'),
|
||||
(join) => join.onTrue(),
|
||||
)
|
||||
.innerJoin('asset_exif', 'a.id', 'asset_exif.assetId')
|
||||
.selectAll('a')
|
||||
.select((eb) => eb.fn.toJson(eb.table('asset_exif')).as('exifInfo')),
|
||||
.selectAll('a'),
|
||||
)
|
||||
.selectFrom('res')
|
||||
.select(sql<number>`date_part('year', ("localDateTime" at time zone 'UTC')::date)::int`.as('year'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user