From fd99121408bfe0601190f91bf1040b503a597352 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Mar 2026 02:27:36 +0000 Subject: [PATCH] Pivot per audit: add nginx vod_response_cache, drop premature DB indexes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add vod_response_cache (64m) to nginx-vod-module config, directly targeting the maintainer-identified bottleneck of manifest/playlist generation on historical playback cold opens - Remove migration 036 (composite recording indexes) — existing indexes are already sufficient; schema expansion deferred until profiling justifies it This aligns with the V2 limited-scope patch plan: 1. nginx VOD response cache (this commit) 2. vod_ts overlap predicate rewrite (prior commit) 3. in-process historical mapping memoization (prior commit) 4. sibling path cleanup in recording_clip (prior commit) https://claude.ai/code/session_01XeVxvSk9ywyPBR288ZZXWE --- .../rootfs/usr/local/nginx/conf/nginx.conf | 1 + migrations/036_add_recordings_vod_indexes.py | 30 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 migrations/036_add_recordings_vod_indexes.py diff --git a/docker/main/rootfs/usr/local/nginx/conf/nginx.conf b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf index 46241c5ab..467bbb872 100644 --- a/docker/main/rootfs/usr/local/nginx/conf/nginx.conf +++ b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf @@ -94,6 +94,7 @@ http { # vod caches vod_metadata_cache metadata_cache 512m; vod_mapping_cache mapping_cache 5m 10m; + vod_response_cache response_cache 64m; # gzip manifests gzip on; diff --git a/migrations/036_add_recordings_vod_indexes.py b/migrations/036_add_recordings_vod_indexes.py deleted file mode 100644 index 4f778a8a7..000000000 --- a/migrations/036_add_recordings_vod_indexes.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Peewee migrations -- 036_add_recordings_vod_indexes.py. - -Add indexes to the recordings table optimized for the VOD overlap query: - WHERE camera = ? AND end_time > ? AND start_time < ? - ORDER BY start_time ASC - -The composite index (camera, start_time, end_time) covers the full predicate -and ordering in a single B-tree walk. The (camera, end_time) index gives the -planner an alternative access path for the end_time > ? filter. -""" - -import peewee as pw - -SQL = pw.SQL - - -def migrate(migrator, database, fake=False, **kwargs): - migrator.sql( - 'CREATE INDEX IF NOT EXISTS "idx_recordings_camera_start_end" ' - 'ON "recordings" ("camera", "start_time", "end_time")' - ) - migrator.sql( - 'CREATE INDEX IF NOT EXISTS "idx_recordings_camera_end" ' - 'ON "recordings" ("camera", "end_time")' - ) - - -def rollback(migrator, database, fake=False, **kwargs): - migrator.sql('DROP INDEX IF EXISTS "idx_recordings_camera_start_end"') - migrator.sql('DROP INDEX IF EXISTS "idx_recordings_camera_end"')