mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 01:16:15 -08:00
The existing single-column indexes force a sort step for the most common list queries. These three composite indexes let SQLite scan in index order and skip the sort entirely: - recently_viewed(playlist_id, viewed_at DESC): getRecentItems(): WHERE playlist_id = ? ORDER BY viewed_at DESC LIMIT 100 - favorites(playlist_id, position, added_at DESC): getFavorites/getGlobalFavorites/getAllGlobalFavorites(): WHERE playlist_id = ? ORDER BY position ASC, added_at DESC - playback_positions(playlist_id, updated_at DESC): getRecentPlaybackPositions(): WHERE playlist_id = ? ORDER BY updated_at DESC LIMIT 20 CREATE INDEX IF NOT EXISTS so existing DBs pick up the new indexes on next startup with no migration required. Mirrored in the Drizzle schema using sql\`col DESC\` so the ORM stays the source of truth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 3d6901072049