mirror of
https://github.com/immich-app/immich.git
synced 2026-10-18 22:46:01 +08:00
200cb8cba4
With orderBy=createdAt (the Recently added page), getTimeBucket filtered on
date_trunc('MONTH', createdAt AT TIME ZONE 'UTC'), which has no matching
index (only the localDateTime month expression is indexed), so every bucket
request read all of the user's assets. Use the equivalent half-open UTC
range instead so asset_createdAt_idx can be combined with the owner index.
Results are identical.
Median per bucket, PG 14:
| user | before | after |
|-------------|--------|---------|
| 10k assets | 29 ms | 4.5 ms |
| 200k assets | 152 ms | 28 ms |
| 600k assets | 149 ms | 98 ms |