goon/alembic/versions
jtrzupek 2163fee245 perf(taxonomy): denormalize scene_count for tags/performers/studios
Counts for /tags, /performers, /studios and /favorites were computed live
per-request by aggregating scene_tags / scene_performers with an EXISTS to
playback_sources. As the catalog grew to ~1.7M scenes (6.3M scene_tags) this
ran ~4.3s for /tags?order=popular (x2 incl. the total count) and ~950ms for
the default /scenes count, making those screens load in several seconds.

- migration 0019: add scene_count (+ DESC index) to tags/performers/studios
- background job _job_refresh_taxonomy_counts (every 3h) recomputes the counts
  in one UPDATE..FROM each (IS DISTINCT FROM to skip unchanged rows)
- /tags, /performers, /studios scenes path now read the column + ORDER BY the
  indexed scene_count; for_movies paths keep live aggregation (small tables)
- favorites read denormalized scene_count instead of a grouped EXISTS aggregate
- /scenes default count: 10-min in-process TTL cache (header is approximate)

Measured: /tags?order=popular&per_page=500 ~8s -> 66ms incl. serialization.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 17:53:48 +02:00
..
20260502_0001_initial.py Initial commit 2026-05-20 10:10:22 +02:00
20260502_0002_playback_sources.py Initial commit 2026-05-20 10:10:22 +02:00
20260503_0003_playback_dead.py Initial commit 2026-05-20 10:10:22 +02:00
20260504_0004_animated_thumbnail.py Initial commit 2026-05-20 10:10:22 +02:00
20260504_0005_favorite_performers.py Initial commit 2026-05-20 10:10:22 +02:00
20260504_0006_blacklists.py Initial commit 2026-05-20 10:10:22 +02:00
20260504_0007_play_progress.py Initial commit 2026-05-20 10:10:22 +02:00
20260506_0008_performer_search_meta.py Initial commit 2026-05-20 10:10:22 +02:00
20260506_0009_movies.py Initial commit 2026-05-20 10:10:22 +02:00
20260506_0010_favorite_scenes.py Initial commit 2026-05-20 10:10:22 +02:00
20260507_0011_origin_pornapp_to_tube.py Initial commit 2026-05-20 10:10:22 +02:00
20260508_0012_favorite_studios.py Initial commit 2026-05-20 10:10:22 +02:00
20260509_0013_bug_reports.py Initial commit 2026-05-20 10:10:22 +02:00
20260509_0014_favorite_movies.py Initial commit 2026-05-20 10:10:22 +02:00
20260510_0015_bug_reports_movie_id.py Initial commit 2026-05-20 10:10:22 +02:00
20260512_0016_realdebrid_cache.py Initial commit 2026-05-20 10:10:22 +02:00
20260512_0017_drop_realdebrid_cache.py Initial commit 2026-05-20 10:10:22 +02:00
20260528_0018_movie_play_progress.py feat(movies): watched/continue-watching tracking end-to-end 2026-05-28 23:24:06 +02:00
20260531_0019_taxonomy_scene_counts.py perf(taxonomy): denormalize scene_count for tags/performers/studios 2026-05-31 17:53:48 +02:00