perf(server): optimize people page query (#27346)

Optimize People page query: modified SQL to use index for faster performance
This commit is contained in:
Tony Fung 2026-03-28 14:33:05 -07:00 committed by GitHub
parent 181b028b09
commit b09ebb11e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -228,12 +228,12 @@ select
from
"asset_face"
left join "asset" on "asset"."id" = "asset_face"."assetId"
and "asset_face"."personId" = $1
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
where
"asset_face"."deletedAt" is null
and "asset_face"."isVisible" is true
and "asset_face"."personId" = $1
-- PersonRepository.getNumberOfPeople
select

View File

@ -352,13 +352,13 @@ export class PersonRepository {
.leftJoin('asset', (join) =>
join
.onRef('asset.id', '=', 'asset_face.assetId')
.on('asset_face.personId', '=', personId)
.on('asset.visibility', '=', sql.lit(AssetVisibility.Timeline))
.on('asset.deletedAt', 'is', null),
)
.select((eb) => eb.fn.count(eb.fn('distinct', ['asset.id'])).as('count'))
.where('asset_face.deletedAt', 'is', null)
.where('asset_face.isVisible', 'is', true)
.where('asset_face.personId', '=', personId)
.executeTakeFirst();
return {