fix: tune up the performance of the getByDayOfYear query. (#26495)

This commit is contained in:
Hao Xi 2026-02-27 16:51:19 -05:00 committed by GitHub
parent dc4da4b3d6
commit aa87d1b9a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 8 deletions

View File

@ -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(

View File

@ -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'))